Postman Cheerio Question

Hi,

I am fairly new to Postman and Cheerio. I have an issue where after an API request has been sent, the response body is in HTML.

I have no control over the response body, and it has been written by a 3rd party who have not given it id’s or labels.

a table is returned in the HTML (which i cannot provide due to it holding sensitive data).

The table has the following mark-up 70 times:

class="data"

example:

<td width="30%" class="data">Beans</td>

When i do the following:

let information= $( "td[class='data']").text();

I get all the data back in a huge block.

Is there a way to get the data to return as an array and pass in the index?

for example:

let information= $( "td[class='data']"[0]).text();

If it helps, this would be the direct XPath

//*[@id="panelBody"]/form/table[1]/tbody/tr[1]/td[4]

let arr = $("td[class='data']").toArray();
let hmm= arr[0].children[0].data;
1 Like