kamike.collect網(wǎng)絡(luò)爬蟲
Another Simple Crawler 又一個(gè)網(wǎng)絡(luò)爬蟲,可以支持代理服務(wù)器的翻墻爬取。
1.數(shù)據(jù)存在mysql當(dāng)中。
2.使用時(shí),先修改web-inf/config.ini的數(shù)據(jù)鏈接相關(guān)信息,主要是數(shù)據(jù)庫名和用戶名和密碼
3.然后訪問http://127.0.0.1/fetch/install 鏈接,自動(dòng)創(chuàng)建數(shù)據(jù)庫表
4.修改src\java\cn\exinhua\fetch中的RestServlet.java文件:
FetchInst.getInstance().running=true;
Fetch fetch = new Fetch();
fetch.setUrl("http://www.washingtonpost.com/");
fetch.setDepth(3);
RegexRule regexRule = new RegexRule();
regexRule.addNegative(".*#.*");
regexRule.addNegative(".*png.*");
regexRule.addNegative(".*jpg.*");
regexRule.addNegative(".*gif.*");
regexRule.addNegative(".*js.*");
regexRule.addNegative(".*css.*");
regexRule.addPositive(".*php.*");
regexRule.addPositive(".*html.*");
regexRule.addPositive(".*htm.*");
Fetcher fetcher = new Fetcher(fetch);
fetcher.setProxyAuth(true);
fetcher.setRegexRule(regexRule);
List<Fetcher> fetchers = new ArrayList<>();
fetchers.add(fetcher);
FetchUtils.start(fetchers);
將其配置為需要的參數(shù),然后訪問http://127.0.0.1/fetch/fetch啟動(dòng)爬取
代理的配置在Fetch.java文件中:
protected int status;
protected boolean resumable = false;
protected RegexRule regexRule = new RegexRule();
protected ArrayList<String> seeds = new ArrayList<String>();
protected Fetch fetch;
protected String proxyUrl="127.0.0.1";
protected int proxyPort=4444;
protected String proxyUsername="hkg";
protected String proxyPassword="dennis";
protected boolean proxyAuth=false;
評論
圖片
表情
