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攻击)
相关文章
相关标签/搜索