# How to parse and extract data from HTML response for Rest API?

**URL:** <https://forum.katalon.com/t/how-to-parse-and-extract-data-from-html-response-for-rest-api/27585>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [June 12, 2019, 2:47pm UTC](https://forum.katalon.com/t/how-to-parse-and-extract-data-from-html-response-for-rest-api/27585 "2019-06-12T14:47:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aalok](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@Aalok](https://forum.katalon.com/u/Aalok)\
**Post date:** [June 12, 2019, 2:47pm UTC](https://forum.katalon.com/t/how-to-parse-and-extract-data-from-html-response-for-rest-api/27585/1 "2019-06-12T14:47:06Z")

</div>

Hi,

Is there any way to parse and extract data from HTML response for Rest API request?

---

<div class="post-metadata">

**Author:** ![Ibus](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@Ibus](https://forum.katalon.com/u/Ibus)\
**Post date:** [June 12, 2019, 3:48pm UTC](https://forum.katalon.com/t/how-to-parse-and-extract-data-from-html-response-for-rest-api/27585/2 "2019-06-12T15:48:02Z")

</div>

yes.  
getResponseBodyContent() or getResponseBodyText() will just return a string with all the content.  
if you need to extract something specific from the html … well, that’s another story.  
you will need a custom parser, depending on the response content

---

<div class="post-metadata">

**Author:** ![Aalok](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@Aalok](https://forum.katalon.com/u/Aalok)\
**Post date:** [June 12, 2019, 8:23pm UTC](https://forum.katalon.com/t/how-to-parse-and-extract-data-from-html-response-for-rest-api/27585/3 "2019-06-12T20:23:24Z")

</div>

Hi,

 ![HtmlResponse](https://europe1.discourse-cdn.com/katalon/original/2X/b/bc8f9eefcf33ecb90bc746de7ee7feaf21576536.png)  
Please find the attached screenshot for reference (postman response).

I want to extract the value for “\_\_VIEWSTATE”

How should I parse this html response and get value for “\_\_VIEWSTATE” ?

---

<div class="post-metadata">

**Author:** ![Ibus](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@Ibus](https://forum.katalon.com/u/Ibus)\
**Post date:** [June 13, 2019, 5:20am UTC](https://forum.katalon.com/t/how-to-parse-and-extract-data-from-html-response-for-rest-api/27585/4 "2019-06-13T05:20:02Z")

</div>

jsoup may help, give it a try:

> **[jsoup: Java HTML parser, built for HTML editing, cleaning, scraping, and XSS...](https://jsoup.org/)**
>
> Open source Java HTML parser, with the best of HTML5 DOM methods and CSS selectors, for easy data extraction.

---

<div class="post-metadata">

**Author:** ![Aalok](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@Aalok](https://forum.katalon.com/u/Aalok)\
**Post date:** [June 13, 2019, 6:31am UTC](https://forum.katalon.com/t/how-to-parse-and-extract-data-from-html-response-for-rest-api/27585/5 "2019-06-13T06:31:54Z")

</div>

Yes, I have tried jsoup and it is working for me. Thanks

---

<div class="post-metadata">

**Author:** ![rodrigocalabretta](https://avatars.discourse-cdn.com/v4/letter/r/b19c9b/32.png) [@rodrigocalabretta](https://forum.katalon.com/u/rodrigocalabretta)\
**Post date:** [December 18, 2019, 10:23pm UTC](https://forum.katalon.com/t/how-to-parse-and-extract-data-from-html-response-for-rest-api/27585/6 "2019-12-18T22:23:13Z")

</div>

@Aalok could you share your code on how you handle it on katalon using jsoup?

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [August 8, 2022, 7:39am UTC](https://forum.katalon.com/t/how-to-parse-and-extract-data-from-html-response-for-rest-api/27585/7 "2022-08-08T07:39:23Z")

</div>


