There is a problem
You need to get and parse an HTML document from a Web site and find the relevant data in it. You can use the following workaround:
Workaround
How to use Jsoup.connect(String url)
:
Document doc = Jsoup.connect("http://example.com/").get();String title = doc.title();
Description
connect (String URL)
method creates a new connection
, and get ()
gets and analyzes an HTML file. If an error occurs when getting HTML from this URL, IOException is thrown and should be handled appropriately.
connection
Interface also provides a method chain to resolve special requests, as follows:
document doc = Jsoup.connect (" http://example.com "). Data (" Query "," Java "). useragent (" Mozilla "). Cookie ("auth", "token"). Timeout (+). Post ();
This method only supports Web URLs ( http
and https
protocols); If you need to load from a file, you can use it parse(File in, String charsetName)
instead.
"Jsoup Learning Rites" loading a document from a URL