前陣子找工作的時候經常會看到epoll多路復用的知識點,無奈自己一點都不懂?;琶χH也只能去了解個 大概 。所以最近閑下來之后想要基于epoll機制實現一個比較有用的東西,剛好最近又想爬些東西,希望這次能夠寫一個高效一點的爬蟲。
以前只看過一點點的nutch,自己寫的就是用python的幾個簡單功能來爬,說真的一點技術含量都沒,就是把網上的代碼拿來改一改,跑一跑,效率沒有,還經常出錯。
Larbin is a web crawler (also called (web) robot, spider, scooter...). It is intended to fetch a large number of web pages to fill the database of a search engine. With a network fast enough, Larbin should be able to fetch more than 100 millions pages on a standard PC.
Larbin is (just) a web crawler, NOT an indexer. You have to write some code yourself in order to save pages or index them in a database.
下載: http://larbin.sourceforge.net/index-eng.html
安裝
下載了larbin2.6.3,README里面的安裝說明很簡單,就是:
1
./
configure
2
make
但是實際需要做些準備工作的:
1
apt-get
install
xutils-dev
這樣執行configure時才能用到makedepend命令。
make的時候出現若干錯誤:
1
parse.c: At top level:
2
parse.c:
113
:
13
: error: conflicting types
for
‘adns__parse_domain’
3
adns_status adns__parse_domain(adns_state ads,
int
serv, adns_query qu,
4
^
5
In
file
included from parse.c:
28
:
0
:
6
internal.h:
569
:
13
: note: previous declaration of ‘adns__parse_domain’ was here
7
adns_status adns__parse_domain(adns_state ads,
int
serv, adns_query qu,
這個簡單,到internal.h把函數聲明改成一樣就行。
1
string
.
cc
:
6
:
22
: fatal error: iostream.h: No such
file
or directory
2
#include <iostream.h>
3
^
4
compilation terminated.
5
make
[
2
]: *** [
string
.o] Error
1
改成<iostream>就行了,用到c++的東西就加上std::也就沒事了。不過有大量文件都出現這種情況。。。這一點還是要吐槽一下。
網上搜了一下,學習了幾條命令用法。
1
sed
-e
'
s/iostream.h/iostream/g
'
-i
`
grep
-rl iostream.h *
`
2
sed
-e
'
s/cerr/std::cerr/g
'
-i
`
grep
-rl cerr *
`
3
sed
-e
'
s/endl/std::endl/g
'
-i
`
grep
-rl endl *`
grep -l表示只打印文件名。
運行
?配置了一下larbin.conf和options.h,注釋寫得都很清楚,重新編譯了一下,試一下京東,爬不下來。
京東的 robots.txt 是這樣子的:
1
User-agent: *
2
Disallow: /?*
3
Disallow: /pop/*
.html
4
Disallow: /pinpai/*.html?*
5
User-
agent: EtaoSpider
6
Disallow: /
User-agent:?*? 這里的 * 代表的所有的搜索引擎種類。
Disallow:?/ 就是不允許爬取所有目錄,看來這兩家(一淘和京東)的確是在死磕。
照這樣子看,應該是可以爬京東的,但就是沒有數據,還是等我看完源碼之后再試試。
改成爬http://demo.aisec.cn/demo/ ,就有數據了。
記
ok,總算是跑起來了,知道larbin有什么功能了,就可以開始看它的實現了。
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061
微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元

