jsoup api中有6
個包提供用於開發jsoup應用程式的類和介面。
- org.jsoup
- org.jsoup.examples
- org.jsoup.helper
- org.jsoup.nodes
- org.jsoup.parser
- org.jsoup.safety
- org.jsoup.salect
以上包中有很多類。 jsoup api中的主要類如下所示:
- Jsoup
- Document
- Element
Jsoup類
org.jsoup.Jsoup
類提供了連接,清理和解析HTML文檔的方法。
org.jsoup.Jsoup
類的重要方法如下:
方法名稱 | 描述 |
---|---|
static Connection connect(String url) |
創建並返回URL的連接。 |
static Document parse(File in, String charsetName) |
將指定的字元集檔解析成文檔。 |
static Document parse(File in, String charsetName, String baseUri) |
將指定的字元集和baseUri檔解析成文檔。 |
static Document parse(String html) |
將給定的html 代碼解析成文檔。 |
static Document parse(String html, String baseUri) |
用baseUri 將給定的html代碼解析成文檔。 |
static Document parse(URL url, int timeoutMillis) |
將給定的URL解析為文檔。 |
static String clean(String bodyHtml, Whitelist whitelist) |
將輸入HTML返回安全的HTML,通過解析輸入HTML並通過允許的標籤和屬性的白名單進行過濾。 |