K6 Load Testing - How extract value from html reponse

I am using K6 Load Testing Tool for the first time.

I send a GET request and html is sent in the response. I then need to extract some values from this html.

What is the best way of doing this in html? I have seen in the documentation that there are the following 3 commands that could possibly be of help:


The HTML is shown below. I want to extract the values of csrf and transId

<html lang="en">

	<link rel="icon" href="data:;base64,iVBORw0KGgo=">
	<script data-container="true" nonce="ekqlmSlKlpMlCSDxgP6erg==">

        var SETTINGS = {

         "csrf": "I NEED THIS VALUE",
         "transId": "I ALSO NEED THIS VALUE",




I think I could do it using Response.body and then searching for a substring. Is this the best way of doing it?

This was already answered and confirmed on stackoverflow, I also added an additional variant as well as expanded on the previous one.