官术网_书友最值得收藏!

How to do it...

  1. Create the Document class structure from Jsoup, depending on the type of input.
    • If the input is a string, use:
      String html = "<html><head><title>jsoup: input with string</title></head><body>Such an easy task.</body></html>";
      Document doc = Jsoup.parse(html);
    • If the input is from a file, use:
      try {
      File file = new File("index.html");
      Document doc = Jsoup.parse(file, "utf-8");
      } catch (IOException ioEx) {
          ioEx.printStackTrace();
      }
    • If the input is from a URL, use:
      Document doc = Jsoup.connect("http://www.example.com").get();
  2. Include the correct package at the top.
    import org.jsoup.Jsoup;
    import.jsoup.nodes.Document;
Note

The complete example source code for this section is in \source\Section01.

The API reference for this section is available at the following location:

http://jsoup.org/apidocs/org/jsoup/Jsoup.html

主站蜘蛛池模板: 且末县| 岑溪市| 通河县| 荆州市| 从江县| 义乌市| 泸定县| 安阳县| 玛纳斯县| 抚远县| 浙江省| 武胜县| 潢川县| 新竹县| 芒康县| 金塔县| 肥东县| 齐齐哈尔市| 景谷| 禹城市| 恭城| 海兴县| 亳州市| 七台河市| 家居| 文水县| 黔江区| 玉屏| 宝清县| 桐庐县| 临沂市| 裕民县| 韶关市| 崇礼县| 贵定县| 宁德市| 沂水县| 保定市| 苗栗县| 徐闻县| 祁门县|