强大的Java HTML 解析器,jsoup 1.6.2 发布
fmms 13年前
<p><a href="http://www.open-open.com/lib/view/open1324372482343.html" target="_blank">jsoup </a>是一款 Java 的HTML 解析器,可直接解析某个URL地址、HTML文本内容。它提供了一套非常省力的API,可通过DOM,CSS以及类似于JQuery的操作方法来取出和操作数据。</p> <p>jsoup的主要功能如下:</p> <ol> <li>从一个URL,文件或字符串中解析HTML; </li> <li>使用DOM或CSS选择器来查找、取出数据; </li> <li>可操作HTML元素、属性、文本; </li> </ol> <p>jsoup是基于MIT协议发布的,可放心使用于商业项目。<br /> 中文版文档:<a href="http://www.open-open.com/jsoup/" target="_blank">http://www.open-open.com/jsoup/</a><br /> </p> <p>jsoup 1.6.2 发布了,改版包含很多的 bug 修复,松散的 XML 解析模式,功能调整以及内存的改进。</p> <p>主要改进内容包括:</p> <p> - Added a simplified XML parsing mode, which can usefully parse valid and invalid XML, but does not enforce any HTML document structure or special tag behaviour.</p> <div> - Added the optional ability to track errors when tokenising and parsing. </div> <div> - Added Jsoup.connect.cookies(Map) method, to set multiple cookies at once, possibly from a prior request. </div> <div> - Added Element.textNodes() and Element.dataNodes(), to easily access an element's children text nodes and data nodes. </div> <div> - Added an example program that demonstrates how to format HTML as plain-text, and the use of the NodeVisitor interface. </div> <div> - Added Node.traverse() and Elements.traverse() methods, to iterate through a node's descendants. </div> <div> - Updated Jsoup.connect() so that when requests made as POSTs are redirected, the redirect is followed as a GET. </div> <div> - Updated the Cleaner and whitelists to optionally preserve related links in elements, instead of converting them to absolute links. </div> <div> - Updated the Cleaner to support custom allowed protocols such as "cid:" and "data:". </div> <div> - Updated handling of base href tags, to act on only the first one seen when parsing, to align with modern browsers. </div> <div> - Updated Node.setBaseUri(), to recursively set on all the node's descendants. </div> <div> Bug fixes: </div> <div> - Fixed an issue where all HTML parse errors where being tracked as new objects, creating high memory pressure on low-memory devices. </div> <div> - Fixed handling of null characters within comments. </div> <div> - Tweaked escaped entity detection in attributes to not treat &entity_... as an entity form. </div> <div> - Fixed doctype tokeniser to allow whitespace between name and public identifier. </div> <div> - Fixed issue where comments within a table tag would be duplicate-fostered into body. </div> <div> - Fixed an issue where a spurious byte-order-mark at the start of a document would cause the parser to miss head contents. </div> <div> - Fixed an issue where content after a frameset could cause a NPE crash. Now correctly implements spec and ignores the trailing content. </div> <div> - Tweaked whitespace checks to align with HTML spec. </div> <div> - Tweaked HTML output of closing script and style tags to not add an extraneous newline when pretty-printing. </div> <div> - Substantially reduced default memory allocation within Node.outerHtml, to reduce memory pressure when serialising smaller DOMs. </div> <p>详情请看官方发行说明:</p> <p><a href="/misc/goto?guid=4958334724236431552">http://jsoup.org/news/release-1.6.2</a></p>