Here is a sample collection to parse the HTML response. Please check if it’s helpful.
Also there are many posts in the forum to parse the HTML response like the above one. Try to explore, if you are not finding the solution please post the response here (if there’s no confidential data) All the best!
Extracted string is a multi-line string, so iterate over it.
If you have to access a particular variable which appears more than once like ID in this case you can put it in an array and access the desired variable as per your need based on the index.
eventually set it in a global or an environment variable as per your usecase
const $ = cheerio.load(pm.response.text());
const scriptString = $("script").text();
const lines = scriptString.split("\n");
for (var i = 0; i < lines.length; i++ )
{
const tokenString = lines[i].trim();
if (tokenString.startsWith('Token:'))
{
console.log(tokenString);
pm.globals.set("findMemToken", tokenString.substring(8, 116));
}
}
console.log(pm.globals.get("findMemToken"));