jsoup 1.12.1 发布,最好的 Java HTML 解析器,没有之一

红薯
 红薯
发布于 2019年05月13日
收藏 62

jsoup 1.12.1 发布了,该版本包含众多可用性的提升,提升了解析速度和内存效率,修复了不少 bug 。

jsoup 是一款 Java 的HTML 解析器,可直接解析某个URL地址、HTML文本内容。它提供了一套非常省力的API,可通过DOM,CSS以及类似于JQuery的操作方法来取出和操作数据。

下载地址:Download 

完整的改进记录如下:

Changes

  • Change: removed deprecated method to disable TLS cert checking in Connection.validateTLSCertificates().
  • Change: some internal methods have been rearranged; if you extended any of the Jsoup internals you may need to make updates.
  • Updated jetty-server (which is used for integration tests) to latest 9.2 series (9.2.28).

Improvements

  • Improvement: documents now remember their parser, so when later manipulating them, the correct HTML or XML tree builder is reused, as are the parser settings like case preservation.
  • Improvement: Jsoup now detects the character set of the input if specified in an XML Declaration, when using the HTML parser. Previously that only happened when the XML parser was specified.
  • Improvement: if the document's input character set does not support encoding, flip it to one that does.
  • Improvement: if a start tag is missing a > and a new tag is seen with a <, treat that as a new tag. (This differs from the HTML5 spec, which would make at attribute with a name beginning with <, but in practice this impacts too many pages.
  • Improvement: performance tweaks when parsing start tags, data, tables.
  • Improvement: added Element.nextElementSiblings() and Element.previousElementSiblings()
  • Improvement: treat center tags as block tags.
  • Improvement: allow forms to be submitted with Content-Type=multipart/form-data without requiring a file upload; automatically set the mime boundary.
  • Improvement: Jsoup will now detect if an input file or URL is binary, and will refuse to attempt to parse it, with an IO Exception. This prevents runaway processing time and wasted effort creating meaningless parsed DOM trees.

Bug Fixes

  • Bugfix: when using the tag case preserving parsing settings, certain HTML tree building rules where not followed for upper case tags.
  • Bugfix: when converting a Jsoup document to a W3C DOM, if an element is namespaced but not in a defined namespace, set it to the global namespace.
  • Bugfix: attributes created with the Attribute constructor with just spaces for names would incorrectly pass validation.
  • Bugfix: some pseudo XML Declarations were incorrectly handled when using the XML Parser, leading to an IOOB exception when parsing.
  • Bugfix: when parsing URL parameter names in an attribute that is not correctly HTML encoded, and near the end of the current buffer, those parameters may be incorrectly dropped. (Improved CharacterReader mark/reset support.)
  • Bugfix: boolean attribute values would be returned as null, vs an empty string, when accessed via the Attribute#getValue() method.
  • Bugix: orphan Attribute objects (i.e. created outside of a parse or an Element) would throw an NPE on Attribute#setValue(val)
  • Bugfix: Element.shallowClone() was not making a clone of its attributes.
  • Bugfix: fixed an ArrayIndexOutOfBoundsException in HttpConnection.looksLikeUtf8() when testing small strings in specific character ranges.
本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创开源社区。
转载请注明:文章转载自 OSCHINA 社区 [http://www.oschina.net]
本文标题:jsoup 1.12.1 发布,最好的 Java HTML 解析器,没有之一
加载中

精彩评论

杜福忠
杜福忠
💗 用过, 是真好用, 瞬间上手!
大刘书生
大刘书生
用来做爬虫的最好组件!
二的基本算合格
二的基本算合格
老捷豹好用了~

最新评论(13

KevinBlandy
KevinBlandy
用它解决xss。
m
marlondu

引用来自“ViperWhip”的评论

用惯了xpath之后乍用这个好不顺手
这个也可以xpath
徐大大啊
徐大大啊
用过,好用,上手快
haohan
haohan
用过一次 很好用
yak
yak
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCer
tPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
八一菜刀
八一菜刀
配合正则表达式使用很爽
大刘书生
大刘书生
用来做爬虫的最好组件!
二的基本算合格
二的基本算合格
老捷豹好用了~
p
pingguo123
真心的好
徐承恩
徐承恩
正则表达式才是王道
返回顶部
顶部