How to get hidden input value using JSoup?

I have data

<input name="authenticity_token" type="hidden" value="aiUlw1Yh4W47lPQearSEdTkU0rhKpziZOweq5PMTV0Q=" />

I am trying to select it using Jsoup.

 Element input = doc.select("input[name=authenticity_token]").first();

 String auth_token = input.attr("value");

But that does not work.

I get a null pointer exception in String auth_token =.

java.lang.NullPointerException at crime.ic.Main.main (Main.java:2)

What am I doing wrong?

+4
source share
2 answers

If you check this demo , you will see that in this case there is no problem with this input.

I believe there may be another input with the same name that has no value. If this is not the case, post a message on the JSoup github page.

0
source

, , : , , JavaScript / . JS , Jsoup. , Jsoup.

/ JS. .

.

0

Source: https://habr.com/ru/post/1620225/


All Articles