91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2.25MB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發布日期: 2023-09-30
  • 語言: Java
  • 標簽: 爬蟲??網頁??

資源簡介

使用java代碼基于MyEclipse開發環境實現爬蟲抓取網頁中的表格數據,將抓取到的數據在控制臺打印出來,需要后續處理的話可以在打印的地方對數據進行操作。包解壓后導入MyEclipse就可以使用,在TestCrawTable中右鍵運行就能看到抓取到的數據。其他的調試可以自行修改。

資源截圖

代碼片段和文件信息

package?com.panchong.test;

import?java.util.ArrayList;
import?java.util.List;
import?java.util.regex.Matcher;
import?java.util.regex.Pattern;

import?org.jsoup.nodes.Document;
import?org.jsoup.nodes.Element;
import?org.jsoup.parser.Tag;
import?org.jsoup.select.Elements;

public?class?DataTableUtil?{

private?final?static?int?NUM?=?5;

//?要抓取的表格可能出現的屬性名
//?static?String[]?Propertys={“企業名稱““注冊號/統一社會信用代碼““被列入經營異常名錄日期“};
static?String[]?Propertys?=?{?“地塊編號“?“宗地編號“?“地塊位置“?“用地性質“?“規劃面積“
“出讓面積“?“發布時間“?“掛牌起始價“?“位置“?“交易時間“?“面積“?“規劃用途“?“容積率“?“起價“
“成交價“?“交易方式“?“競得人“?};

//?取最里面的table進入isValueElement方法檢測是不是我們需要的table
public?static?List?getFitElement(Document?document)?{
if?(Propertys?!=?null)?{
Element?element?=?document.getElementsByTag(“body“).get(0);
List?fitElments?=?new?ArrayList();
Elements?tableElements?=?element.getElementsByTag(“table“);
if?(tableElements?!=?null?&&?tableElements.size()?>?0)?{
for?(int?i?=?0;?i? Element?tableElement?=?tableElements.get(i);
Elements?ces?=?tableElement.getElementsByTag(“table“);
if?(ces?!=?null?&&?ces.size()?>?1)?{
}?else?{
TableElement?te;
if?((te?=?isValueElement(Propertys?tableElement))?!=?null)?{
fitElments.add(te);
}
}
}
}?else?{
return?null;
}
return?fitElments;
}
return?null;
}

private?static?Element?removeRedundance(String[]?Propertys?Element?element)?{
Elements?tres?=?element.getElementsByTag(“tr“);
Element?trElement?=?tres.get(0);
Elements?tde?=?trElement.getElementsByTag(“td“);
int?row?=?1;
for?(Element?tdElement?:?tde)?{
String?attribute?=?tdElement.attr(“rowspan“);
if?(attribute?!=?null?&&?!attribute.equals(““))?{
int?rowSpan?=?Integer.valueOf(attribute);
if?(rowSpan?>?row)?{
row?=?rowSpan;
}
}
}
List?elements?=?new?ArrayList();
for?(int?i?=?0;?i? elements.add(tres.get(i));
}
int?ri?=?0;
while?(!isValueElements(Propertys?elements))?{
elements?=?new?ArrayList();
row?=?1;
Elements?tdes?=?tres.get(ri).getElementsByTag(“td“);
for?(Element?tdElement?:?tdes)?{
String?attribute?=?tdElement.attr(“rowspan“);
if?(attribute?!=?null?&&?!attribute.equals(““))?{
int?rowSpan?=?Integer.valueOf(attribute);
if?(rowSpan?>?row)?{
row?=?rowSpan;
}
}
}
for?(int?i?=?0;?i? elements.add(tres.get(ri?+?i));
}
ri?=?ri?+?row;
}
if?(ri?>?0)?{
Elements?trs?=?element.getElementsByTag(“tr“);
int?size?=?trs.size();
Element?newElement?=?new?Element(Tag.valueOf(“table“)?“table“);
for?(int?i?=?ri?-?row;?i? newElement.appendChild(trs.get(i));
}
return?newElement;
}
return?element;
}

private?static?boolean?isValueElements(String[]?Propertys

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????????885??2016-12-09?17:47??PanChongTest\.classpath

?????文件????????388??2016-12-09?17:15??PanChongTest\.project

?????文件????????598??2016-12-09?17:15??PanChongTest\.settings\org.eclipse.jdt.core.prefs

?????文件??????36586??2016-12-09?17:16??PanChongTest\bin\chardet.jar

?????文件???????7712??2016-12-15?15:28??PanChongTest\bin\com\panchong\test\DataTableUtil.class

?????文件????????732??2016-12-09?17:47??PanChongTest\bin\com\panchong\test\PropertyInfo.class

?????文件???????1548??2016-12-09?17:47??PanChongTest\bin\com\panchong\test\SimFeatureUtil.class

?????文件???????1150??2016-12-09?17:47??PanChongTest\bin\com\panchong\test\StringUtil.class

?????文件????????991??2016-12-09?17:47??PanChongTest\bin\com\panchong\test\TableElement.class

?????文件???????8053??2016-12-09?17:47??PanChongTest\bin\com\panchong\test\TableUtil.class

?????文件???????2277??2016-12-15?15:26??PanChongTest\bin\com\panchong\test\TestCrawTable.class

?????文件?????207723??2016-12-09?17:16??PanChongTest\bin\commons-lang.jar

?????文件??????55424??2016-12-09?17:16??PanChongTest\bin\commons-logging.jar

?????文件??????51526??2016-12-09?17:16??PanChongTest\bin\cpdetector.jar

?????文件?????433368??2016-12-09?17:16??PanChongTest\bin\httpclient-4.2.5.jar

?????文件?????227275??2016-12-09?17:16??PanChongTest\bin\httpcore-4.2.4.jar

?????文件?????293672??2016-12-09?17:16??PanChongTest\bin\jsoup-1.7.2.jar

?????文件??????36586??2016-12-09?17:16??PanChongTest\lib\chardet.jar

?????文件?????207723??2016-12-09?17:16??PanChongTest\lib\commons-lang.jar

?????文件??????55424??2016-12-09?17:16??PanChongTest\lib\commons-logging.jar

?????文件??????51526??2016-12-09?17:16??PanChongTest\lib\cpdetector.jar

?????文件?????433368??2016-12-09?17:16??PanChongTest\lib\httpclient-4.2.5.jar

?????文件?????227275??2016-12-09?17:16??PanChongTest\lib\httpcore-4.2.4.jar

?????文件?????293672??2016-12-09?17:16??PanChongTest\lib\jsoup-1.7.2.jar

?????文件???????6993??2016-12-15?15:28??PanChongTest\src\com\panchong\test\DataTableUtil.java

?????文件????????341??2016-12-09?17:19??PanChongTest\src\com\panchong\test\PropertyInfo.java

?????文件???????1370??2016-12-09?17:36??PanChongTest\src\com\panchong\test\SimFeatureUtil.java

?????文件????????451??2016-12-09?17:18??PanChongTest\src\com\panchong\test\StringUtil.java

?????文件????????608??2016-12-09?17:17??PanChongTest\src\com\panchong\test\TableElement.java

?????文件???????8531??2016-12-09?17:37??PanChongTest\src\com\panchong\test\TableUtil.java

............此處省略15個文件信息

評論

共有 條評論