python 编写的DHT Crawler 网络爬虫

1、安装boost依赖和编译环境。

yum install -y boost boost-devel

yum install -y make gcc gcc-c++ kernel-devel python-devel

2、装 libtorrent 的 python 绑定库

#下载到本地
cd  /opt/software

wget https://github.com/arvidn/libtorrent/releases/download/libtorrent-1_0_10/libtorrent-rasterbar-1.0.10.tar.gz


#解压
cd  /opt/software/libtorrent-rasterbar-1.0.10.tar.gz
tar  -xf  libtorrent-rasterbar-1.0.10.tar.gz -C /opt


#编译,安装,根据系统性能,虚拟机上时间有点长
./configure --disable-debug --with-boost-libdir=/usr/lib64 --disable-encryption --enable-python-binding
make && make install


#配置库文件环境变量
export LD_LIBRARY_PATH=/usr/local/lib/

#绑定
cd bindings/python
python setup.py build
python setup.py install

3、安装 twisted 网络库

pip install twisted

4、开放防火墙的对应端口段,目前默认的是 32900--32920 (20是工作的p2p客户端数量)

这里我们的虚拟机的防火墙是关闭的状态。

5、运行方法

  • 下载 collector.py collectord.py 文件到安装目录
git clone  https://github.com/blueskyz/DHTCrawler.git
  • 脚本方式测试运行:
 python collector.py result.json collector.state
  • 服务方式运行:
twistd -y collectord.py

6、查看结果:

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值