Probably stupid question, but I need a simple way to find a string in an html page using Jsoup.
For example I need a simple way to find Capocchia
on my document.
Document doc = Jsoup.connect("http://example.com/").execute();
String myString = doc.parse;
And then? what I should use? I don't know in which selector my text will be, it could be in a
, p
, span
, div
and other...
Well that is a rather difficult question to answer! If you don't know, we can't know either. If you're looking for a generic answer to "get whatever I need from wherever I need" I'm afraid it isn't that simple.
You could always try and look here for the selector documentation, or you can upgrade that answer's description
This is simple:
Document page = Jsoup.connect("http://www.zomato.com/mumbai/starbucks-coffee-fort").get();
boolean containsCapocchia = page.text().contains("Capocchia");
System.out.println(containsCapocchia);
For this page result is false
;)
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.