Getting HTML response - want to parse certain fields to next request

Please, let me know how to parse some fields from HTML response to next request.
Similar to this command for JSON response

var data = JSON.parse(responseBody);

I’m trying to get fields by id from

<!DOCTYPE html>

    <input type="hidden" name="ID1" id="ID1" value="dfbldbldb" />
    <input type="hidden" name="templateID" id="templateID" value="sdfjsbh skjd" />
    <input type="hidden" name="ID2" id="ID2" value="sfsighs87y" />
    <input type="hidden" name="templateName" id="templateName" value="template name here" />


Hey @yglprn. The Postman Sandbox has cheerio as one of the supported libraries which you can use to parse HTML responses. Here’s what your use case might look like.

var html = cheerio(responseBody),
 id1 = html.find('#ID1').attr('value'),
 templateId = html.find('#templateID').attr('value'),
 id2 = html.find('#ID2').attr('value'),
 templateName = html.find('#templateName').attr('value');
console.log(id1, templateId, id2, templateName);
sdfjsbh skjd
template name here

You can update the value specified in.attr() as per your needs. Feel free to reach out if you have additional queries.

1 Like