- INSTANT Jsoup How-to
- Pete Houston
- 112字
- 2021-08-20 16:52:35
How to do it...
- 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();
- If the input is a string, use:
- 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:
推薦閱讀
- 觸·心:DT時(shí)代的大數(shù)據(jù)精準(zhǔn)營(yíng)銷(xiāo)
- Vue.js 2 and Bootstrap 4 Web Development
- Java從入門(mén)到精通(第4版)
- Scala編程實(shí)戰(zhàn)(原書(shū)第2版)
- Java程序設(shè)計(jì)入門(mén)
- Visual Basic程序設(shè)計(jì)教程
- 深度學(xué)習(xí):Java語(yǔ)言實(shí)現(xiàn)
- 智能搜索和推薦系統(tǒng):原理、算法與應(yīng)用
- OpenCV with Python By Example
- Unity 2018 Augmented Reality Projects
- FPGA嵌入式項(xiàng)目開(kāi)發(fā)實(shí)戰(zhàn)
- 交互設(shè)計(jì)師成長(zhǎng)手冊(cè):從零開(kāi)始學(xué)交互
- DevOps 精要:業(yè)務(wù)視角
- C/C++代碼調(diào)試的藝術(shù)(第2版)
- Mastering Python