jeff king jeff king - 1 year ago 77
HTML Question

Regex scrape of the same form_id name but different values

I would like to know using either regex or xpath how can you scrape a form id value from a html page that has the same form_id names example below, I would to scrape the value from the 2nd form_id name any advice for the best way to achieve this using only regex or xpath? Thanks

<input type="hidden" name="form_id" value="search_block_form" />

I would like to scrape the value from this form_id below: "webform_client_form_"

<input type="hidden" name="form_id" value="webform_client_form_" />

Answer Source

Targeting second input with XPath:


Using utilities that work on DOM structure is the preferable choice here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download