### 1.載入文件
從URL加載文檔,使用`Jsoup.connect()`方法從URL加載HTML。
```
public static void main(String[] args) throws IOException{
try
{
Document document = Jsoup.connect("https://trustie.educoder.net").get();
//String title=document.title();
System.out.println(document.title());
//System.out.println(document);
}
catch (IOException e)
{
e.printStackTrace();
}
}
```
### 2.從文件加載文檔
使用`Jsoup.parse()`方法從文件加載HTML。
```
public static void main(String[] args) throws IOException{
try
{
Document document = Jsoup.parse( new File( "C:\\Users\\Administrator\\Desktop\\1.html" ) , "utf-8" );
System.out.println(document.title());
System.out.println(document);
}
catch (IOException e)
{
e.printStackTrace();
}
}
```
### 3.從String加載文檔
使用`Jsoup.parse()`方法從字符串加載HTML。
```
public static void main(String[] args) throws IOException{
String html = "<html><head><title>First parse</title></head>"
+ "<body><p>this is number</p></body></html>";
Document document = Jsoup.parse(html);
System.out.println(document);
}
```