jsoup是一款Java的HTML解析器,可直接解析某个URL地址、HTML文本内容。它提供了一套非常省力的API,可通过DOM,CSS以及类似于JQuery的操作方法来取出和操作数据。
jsoup的主要功能如下:
从一个URL,文件或字符串中解析HTML;
使用DOM或CSS选择器来查找、取出数据;
可操作HTML元素、属性、文本;
jsoup是基于MIT协议发布的,可放心使用于商业项目。
此次更新内容:
改进
CDATAsectionsarenowtreatedaswhitespacepreserving(regardlessofthecontainingelement),andareround-trippedintooutputHTML.
AddedsupportforDeflateencoding.
Whenparsing<pre>tags,skipthefirstnewlineifpresent.
Supportnestedquotesforattributeselectionqueries.
CharacterreferencesfromWindows-1252thatarenotvalidUnicodearemappedtotheappropriateUnicodereplacement.
AcceptacustomSSLsocketfactoryinJsoup.Connection.NotethatConnection.validateTLSCertificates()willberemovedinthenextrelease;Connection.sslSocketFactory(SSLSocketFactorysslSocketFactory)providesapathtoimplementaworkaroundifyouneedtokeepusingasimilarapproach.
Bug修复
Bugfix:AMarkhasbeeninvalidatedexceptionwasthrownwhenparsingsomeURLsonAndroid<=6.
Bugfix:TheElement.text()for<div>One</div>TwowasOneTwo,notOneTwo.
Bugfix:booleanattributeswithemptystringvalueswerenotcollapsinginHTMLoutput.
Bugfix:whenusingtheXMLParsersettolowercasenormalizetags,uppercaseclosingtagswerenotcorrectlyhandled.
Bugfix:whenparsingfromaURL,anendtagcouldbereadincorrectlyifitstartedonabufferboundary.