# Parse HTML form response data and extract form attributes

**URL:** <https://community.postman.com/t/parse-html-form-response-data-and-extract-form-attributes/3562>\
**Category:** Help Hub\
**Tags:** postman, cheerio\
**Created:** [December 11, 2018, 4:23pm UTC](https://community.postman.com/t/parse-html-form-response-data-and-extract-form-attributes/3562 "2018-12-11T16:23:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hesam.kamalan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/hesam.kamalan/32/1166_2.png) [@hesam.kamalan](https://community.postman.com/u/hesam.kamalan)\
**Post date:** [December 11, 2018, 4:23pm UTC](https://community.postman.com/t/parse-html-form-response-data-and-extract-form-attributes/3562/1 "2018-12-11T16:23:23Z")

</div>

I have a form in response like blow code. I want to get “action” and “method” using cheerio lib. How can I do that?

```
<form action="https://my.url.com" method="post">
    .....
    <input type="submit" value="Submit" />
</form>
```

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/matt/32/2562_2.png) [@matt](https://community.postman.com/u/matt)\
**Post date:** [December 11, 2018, 11:03pm UTC](https://community.postman.com/t/parse-html-form-response-data-and-extract-form-attributes/3562/2 "2018-12-11T23:03:53Z")

</div>

```auto
const $ = cheerio.load(responseBody);

const $form = $('form');
const action = $form.attr('action');
const method = $form.attr('method');

```

Here’s a link to the cheerio website which includes more advanced examples should you need them:

> **[cheerio](https://cheerio.js.org/)**
>
> Fast, flexible, and lean implementation of core jQuery designed specifically for the server.

---

<div class="post-metadata">

**Author:** ![hesam.kamalan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/hesam.kamalan/32/1166_2.png) [@hesam.kamalan](https://community.postman.com/u/hesam.kamalan)\
**Post date:** [December 14, 2018, 5:34am UTC](https://community.postman.com/t/parse-html-form-response-data-and-extract-form-attributes/3562/3 "2018-12-14T05:34:08Z")

</div>

Okay, I found it this way:  
console.log($( ‘form’ ).attr(‘action’));

---

<div class="post-metadata">

**Author:** ![gpub1](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gpub1](https://community.postman.com/u/gpub1)\
**Post date:** [March 4, 2021, 10:20pm UTC](https://community.postman.com/t/parse-html-form-response-data-and-extract-form-attributes/3562/4 "2021-03-04T22:20:21Z")

</div>

> [@hesam.kamalan](#):
>
> console.log($( ‘form’ ).attr(‘action’));

error  
@hesam.kamalan @matt

lets say url is `/appstest/RunUpdate?id=26216&requestId=1614895894455&ln=1000043845` want to print `id, requestId, ln` values only in console

How to extract all the href links with submit linknames from below html response

```auto
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>appstest Import System: Loans Processed</title>
<link rel="stylesheet" type="text/css" href="/appstest/css-table.css">
<script type="text/javascript" src="/appstest/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="/appstest/appstest.js"></script>
</head>
<body>
<table width="100%"><caption>Loans in process queue (Sorted by last modified)</caption>
<thead><tr>
<th scope="col">File Name</th>
<th scope="col">Loan Number</th>
<th scope="col">Date Created</th>
<th scope="col">Last Modified</th>
<th scope="col">Request</th>
</tr></thead><tbody>
<tr><td>FILECheckTestLoans.xlsx</td><td><a href=/LoanServicing/GetLoanData?loannumber=1000043845 target=loanDetail>1000043845</a></td><td>2021-03-04 15:37:49.437</td><td>2021-03-04 15:37:49.437</td><td><a href=/appstest/RunUpdate?id=26088&requestId=1614893866191&ln=1000043845 target=_new>Submit</td></tr><tr><td>FILECheckTestLoans.xlsx</td><td><a href=/LoanServicing/GetLoanData?loannumber=1000043833 target=loanDetail>1000043833</a></td><td>2021-03-04 15:37:49.437</td><td>2021-03-04 15:37:49.437</td><td><a href=/appstest/RunUpdate?id=26089&requestId=1614893866191&ln=1000043833 target=_new>Submit</td></tr><tr><td>FILECheckTestLoans.xlsx</td><td><a href=/LoanServicing/GetLoanData?loannumber=1000043832 target=loanDetail>1000043832</a></td><td>2021-03-04 15:37:49.437</td><td>2021-03-04 15:37:49.437</td><td><a href=/appstest/RunUpdate?id=26090&requestId=1614893866191&ln=1000043832 target=_new>Submit</td></tr><tr><td>FILECheckTestLoans.xlsx</td><td><a href=/LoanServicing/GetLoanData?loannumber=1000043831 target=loanDetail>1000043831</a></td><td>2021-03-04 15:37:49.437</td><td>2021-03-04 15:37:49.437</td><td><a href=/appstest/RunUpdate?id=26091&requestId=1614893866191&ln=1000043831 target=_new>Submit</td></tr><tr><td>FILECheckTestLoans.xlsx</td><td><a href=/LoanServicing/GetLoanData?loannumber=1000043845 target=loanDetail>1000043845</a></td><td>2021-03-04 15:37:49.437</td><td>2021-03-04 15:37:49.437</td><td><a href=/appstest/RunUpdate?id=26092&requestId=1614893866191&ln=1000043845 target=_new>Submit</td></tr><tr><td>FILECheckTestLoans.xlsx</td><td><a href=/LoanServicing/GetLoanData?loannumber=1000043833 target=loanDetail>1000043833</a></td><td>2021-03-04 15:37:49.437</td><td>2021-03-04 15:37:49.437</td><td><a href=/appstest/RunUpdate?id=26093&requestId=1614893866191&ln=1000043833 target=_new>Submit</td></tr><tr><td>FILECheckTestLoans.xlsx</td><td><a href=/LoanServicing/GetLoanData?loannumber=1000043832 target=loanDetail>1000043832</a></td><td>2021-03-04 15:37:49.437</td><td>2021-03-04 15:37:49.437</td><td><a href=/appstest/RunUpdate?id=26094&requestId=1614893866191&ln=1000043832 target=_new>Submit</td></tr><tr><td>FILECheckTestLoans.xlsx</td><td><a href=/LoanServicing/GetLoanData?loannumber=1000043831

```
