Skip to content

code4craft/jsoup-learning

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

Jsoup学习笔记

Jsoup是Java世界的一款HTML解析工具,它支持用CSS Selector方式选择DOM元素,也可过滤HTML文本,防止XSS攻击。

学习Jsoup是为了更好的开发我的另一个爬虫框架webmagic,为了学的比较详细,就强制自己用很规范的方式写出这部分文章。

代码部分来自https://github.com/jhy/jsoup,添加了一些中文注释以及示例代码。


提纲

  1. 概述

  2. DOM相关对象

  3. Document的输出

  4. HTML语法分析parser

    1. 语法分析与状态机基础
    2. 词法分析Tokenizer
    3. 语法检查及DOM树构建
  5. CSS Selector

  6. 防御XSS攻击

  7. 为Jsoup增加XPath选择功能

    Jsoup默认没有XPath功能,我写了一个项目Xsoup,可以使用XPath来选择HTML文本。Java里较常用的XPath抽取器是HtmlCleaner,Xsoup的性能比它快了一倍。


协议:

相关代码遵循MIT协议。

文档遵循CC-BYNC协议。

Bitdeli Badge

About

Jsoup学习笔记。添加了部分学习代码和注释。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages