jsoup( HTML parser ) cookbook

Introduction

  1. Parsing and traversing a Document

Input

  1. Parse a document from a String
  2. Parsing a body fragment
  3. Load a Document from a URL
  4. Load a Document from a File

Extracting data

  1. Use DOM methods to navigate a document
  2. Use selector-syntax to find elements
  3. Extract attributes, text, and HTML from elements
  4. Working with URLs
  5. Example program: list links

Modifying data

  1. Set attribute values
  2. Set the HTML of an element
  3. Setting the text content of elements

Cleaning HTML

  1. Sanitize untrusted HTML (to prevent XSS)

Cookbook 目錄

入門

  1. 解析和遍歷一個html文檔

輸入

  1. 解析一個html字符串
  2. 解析一個body片段
  3. 從一個URL加載一個Document對象
  4. 根據一個文件加載Document對象

數據抽取

  1. 使用dom方法來遍歷一個Document對象
  2. 使用選擇器語法來查找元素
  3. 從元素集合抽取屬性、文本和html內容
  4. URL處理
  5. 程序示例:獲取全部連接

數據修改

  1. 設置屬性值
  2. 設置元素的html內容
  3. 設置元素的文本內容

HTML清理

  1. 消除不受信任的html (來防止xss攻擊)
相關文章
相關標籤/搜索