- INSTANT Jsoup How-to
- Pete Houston
- 186字
- 2021-08-20 16:52:35
How it works...
Basically, all the inputs will be given to the Jsoup
class to parse.
For an HTML string, you just need to pass the HTML string as parameter for the method Jsoup.parse()
.
For an HTML file, there are three parameters inputted for Jsoup.parse()
. The first one is the file object, which points to the specified HTML file; the second one is the character set of the file. There is an overload of this method with an additional third parameter, Jsoup.parse(File file, String charsetName, String baseUri)
. The baseUri
URL is the URL from where the HTML file is retrieved; it is used to resolve relative paths or links.
For a URL, you need to use the Jsoup.connect()
method. Once the connection succeeds, it will return an object, thus implementing the connection interface. Through this, you can easily get the content of the URL page using the Connection.get()
method.
The previous example is pretty easy and straightforward. The results of parsing from the Jsoup
class will return a Document
object, which represents a DOM structure of an HTML page, where the root node starts from <html>
.
- 手機(jī)安全和可信應(yīng)用開發(fā)指南:TrustZone與OP-TEE技術(shù)詳解
- Android開發(fā)精要
- Java高手真經(jīng)(高級編程卷):Java Web高級開發(fā)技術(shù)
- HTML5入門經(jīng)典
- JavaScript入門經(jīng)典
- C語言程序設(shè)計(jì)教程
- 領(lǐng)域驅(qū)動(dòng)設(shè)計(jì):軟件核心復(fù)雜性應(yīng)對之道(修訂版)
- Visual Basic程序設(shè)計(jì)
- 愛上micro:bit
- 小程序,巧應(yīng)用:微信小程序開發(fā)實(shí)戰(zhàn)(第2版)
- Android嵌入式系統(tǒng)程序開發(fā):基于Cortex-A8(第2版)
- 智能手機(jī)故障檢測與維修從入門到精通
- Java Web應(yīng)用開發(fā)給力起飛
- PHP與MySQL權(quán)威指南
- C語言從入門到精通(視頻實(shí)戰(zhàn)版)