# How can we get the variable value from script tag of HTML response using javascirpt

**URL:** <https://community.postman.com/t/how-can-we-get-the-variable-value-from-script-tag-of-html-response-using-javascirpt/21141>\
**Category:** Help Hub\
**Created:** [March 8, 2021, 10:03pm UTC](https://community.postman.com/t/how-can-we-get-the-variable-value-from-script-tag-of-html-response-using-javascirpt/21141 "2021-03-08T22:03:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aravi.a620](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@aravi.a620](https://community.postman.com/u/aravi.a620)\
**Post date:** [March 8, 2021, 10:03pm UTC](https://community.postman.com/t/how-can-we-get-the-variable-value-from-script-tag-of-html-response-using-javascirpt/21141/1 "2021-03-08T22:03:46Z")

</div>

I would like to get the ‘g\_listData’ from the following HTML response using Javascript.

```
    <html>
        <body>
        <script type="text/javascript">

        var g_deferData= "testdata";

        var g_listData = {"ListData":{ "Row" : [{
        	"ID": "85018",
        	"FileLeafRef": "test only"
        	}
        	,{
        	"ID": "85091",
        	"FileLeafRef": "completed"
        	}]
          }}
        </script>
        </body>
     </html>
```

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [March 8, 2021, 10:56pm UTC](https://community.postman.com/t/how-can-we-get-the-variable-value-from-script-tag-of-html-response-using-javascirpt/21141/2 "2021-03-08T22:56:58Z")

</div>

Hey @aravi.a620 👋

What have you tried so far?

There have been many posts on the community site around using cheerio to extract different pieces of data from those kinds of responses.

---

<div class="post-metadata">

**Author:** ![aravi.a620](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@aravi.a620](https://community.postman.com/u/aravi.a620)\
**Post date:** [March 11, 2021, 8:24pm UTC](https://community.postman.com/t/how-can-we-get-the-variable-value-from-script-tag-of-html-response-using-javascirpt/21141/3 "2021-03-11T20:24:47Z")

</div>

Hi @danny-dainton,

I found a simple solution, I just used the split() method inside content. I never used cheerio earlier but it looks very interesting, maybe I will use it later especially to parse my XML response. Thanks
