Parsing Html content using Jsoup

后端 未结 1 1676
渐次进展
渐次进展 2021-01-25 16:55

This is my HTML source

             
  • Item 1
    111&
  • 相关标签:
    1条回答
    • 2021-01-25 17:37

      Try this for easy parsing using jsoup:

      // To parse the html page
      Document doc = Jsoup.connect("http://www.website.com").get();
      Document doc1 = Jsoup.parse("<html><head><title>First parse</title></head>" + "<body> <p>Parsed HTML into a doc.</p></body></html>");
      
      String content = doc.body().text();
      
      // To get specific elements such as links
      Element links = doc.select("a[href]");
      for(Element e: links){
          System.out.println("link: " + e.attr("abs:href"));
      }
      

      To learn more, visit Jsoup Docs

      0 讨论(0)
    提交回复
    热议问题