Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jsoup - get the action of a form

Basically, I have a form.

<form id="frm1" action="random.php" >
<input ... />
<input ... type=hidden name=id value=random_number />
</form>

I need to get the two random values. The action and the hidden value called id. The id of the form does not change. It is always frm1. I am totally confused on how to do this. I can select the form but don't know what to do from there.

Hoping for help. Thanks

like image 860
rahules Avatar asked Dec 04 '25 11:12

rahules


1 Answers

If you haven't already you should look at this http://jsoup.org/cookbook/extracting-data/dom-navigation

There's a method on Element called attr(String key) In your case formElement.attr("action") should return "random.php"

To get the second random number, if there is not an id on the element, you can use formElement.children() and just iterate the child elements looking for whatever qualifiers you want and pull out the value attribute.

like image 137
Ahbutfore Avatar answered Dec 07 '25 05:12

Ahbutfore



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!