I am writing a Java application which tries to fetch contents from a web page. I try to write code which is given below.
When I try to fetch all links(html <a>
tag) from the website my code works well, but when I try to fetch a value from input type="hidden"
tag I have a problem.
String url = "http://www.justdial.com/Bangalore/pc-repair-%3Cnear%3E-jp-nagaer";
Document doc = Jsoup.connect(url).get();
Elements input = doc.select("a[href]");
System.out.print(input);
This code works fine.. it gives all the links included in this website.. but I want the value from input type="hidden"
. What to do I have to do?
If I do doc.select("input[hidden]")
then result comes with a null
value.
You should use
doc.select("input[type=hidden]")
to get the tags you want. Your proposed version will return all <input hidden="..">
tags not those with <input type="hidden">
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.