-
大小: 103KB文件類型: .rar金幣: 1下載: 0 次發(fā)布日期: 2021-01-07
- 語言: Java
- 標(biāo)簽: htmlcleaner??jar包??java??爬蟲??
資源簡介
一個(gè)最簡單的htmlcleaner扒網(wǎng)頁內(nèi)容,demo中以58種的一個(gè)頁面為例,xpath請(qǐng)通過chrome瀏覽器控制臺(tái)選中需要的內(nèi)容后右擊選擇復(fù)制xpath 不喜勿噴,資源免費(fèi)下載
代碼片段和文件信息
package?com.space;
import?java.net.URL;
import?org.htmlcleaner.HtmlCleaner;
import?org.htmlcleaner.TagNode;
public?class?HtmlCleanerDemo
{
public?static?void?main(String[]?args)?throws?Exception
{
try
{
HtmlCleaner?cleaner?=?new?HtmlCleaner();
URL?url?=?new?URL(
“http://haikou.58.com/baomu/23058539091978x.shtml?adtype=1&entinfo=23058539091978_0&adact=3&psid=118324118190869277073175706“);
//?URL?url?=?new?URL(“http://haikou.58.com/baomu/21632367579150x.shtml?adtype=1&entinfo=21632367579150_0&adact=3&psid=101062395190937233949225183“);
//?URL?url?=?new?URL(“http://www.hizw.gov.cn/data/news/2016/02/57095“);
TagNode?node?=?cleaner.clean(url?“utf-8“);
object[]?tagNodes?=?node.evaluateXPath(“//*[@id=‘sub_1‘]/div“);?//?找到標(biāo)簽中id為nv的
標(biāo)簽
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件?????107947??2012-10-08?15:25??htmlcleaner2.2\htmlcleaner-2.2.jar
?????文件????????383??2016-06-27?11:06??Test\.classpath
?????文件????????380??2016-06-27?11:03??Test\.project
?????文件????????598??2016-06-27?11:03??Test\.settings\org.eclipse.jdt.core.prefs
?????文件???????2391??2016-06-27?15:55??Test\bin\com\space\HtmlCleanerDemo.class
?????文件???????2652??2016-06-27?16:00??Test\src\com\space\HtmlCleanerDemo.java
?????目錄??????????0??2016-06-27?16:00??Test\bin\com\space
?????目錄??????????0??2016-06-27?16:01??Test\src\com\space
?????目錄??????????0??2016-06-27?16:00??Test\bin\com
?????目錄??????????0??2016-06-27?16:00??Test\src\com
?????目錄??????????0??2016-06-27?16:00??Test\.settings
?????目錄??????????0??2016-06-27?16:00??Test\bin
?????目錄??????????0??2016-06-27?16:00??Test\src
?????目錄??????????0??2016-06-27?16:00??htmlcleaner2.2
?????目錄??????????0??2016-06-27?16:00??Test
-----------?---------??----------?-----??----
???????????????114351????????????????????15
評(píng)論
共有 條評(píng)論