Jsoup - get form action

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 two random values. Action and hidden value called id. The form ID is not changed. It is always frm1. I am completely confused on how to do this. I can choose a shape, but I don't know what to do from there.

Hope for help. thank

+3


source to share


1 answer


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

There the method Element

is not called. attr(String key)

In your case, it formElement.attr("action")

should return "random.php"



To get the second random number if there is no id in the element, you can use formElement.children()

and just iterate over the child elements looking for whatever criteria you need and pull out the value attribute.

+4


source







All Articles