Load a Document from a URL using jsoup

使用 Jsoup.connect(String url)方法:
String url="http://www.baidu.com";Document doc = Jsoup.connect(url).get();







illustrate

connect(String url) methods to create a new one  Connection, and  get() get and parse an HTML file. If there is an error fetching the HTML from this URL, an IOException will be thrown and should be handled appropriately.

Connection The interface also provides a method chain to resolve special requests, as follows:


String url="http://www.baidu.com";Document doc = Jsoup.connect(url)
  .data("query", "Java")
  .userAgent("Mozilla")
  .cookie("auth", "token")
  .timeout(3000)
  .post();

This method only supports Web URLs ( httpand https protocols); if you need to load from a file, use it  parse(File in, String charsetName) instead.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325475810&siteId=291194637