前言
爬虫代理IP池项目,主要功能为定时采集网上发布的免费代理验证入库,定时验证入库的代理保证代理的可用性,提供API和CLI两种使用方式。同时你也可以扩展代理源以增加代理池IP的质量和数量。(Github)
通过jhao104/proxy_pool实现自建代理池
下载项目
1 2
| git clone https://github.com/jhao104/proxy_pool.git cd proxy_pool
|
下载依赖
1 2 3
| python3 -m venv venv source venv/bin/activate pip install -r requirements.txt
|
修改配置文件
setting.py1
| DB_CONN = 'redis://:<password>@127.0.0.1:6379/0'
|
setting.py1
| DB_CONN = 'redis://:@127.0.0.1:6379/0'
|
启动爬虫
1
| python proxyPool.py schedule
|
启动API服务
1
| python proxyPool.py server
|
调用API
查看API介绍
1
| curl http://127.0.0.1:5010
|
随机获取一个代理
1
| curl http://127.0.0.1:5010/get
|
1
| curl http://127.0.0.1:5010/get?type=https
|
随机获取并删除一个代理
1
| curl http://127.0.0.1:5010/pop
|
1
| curl http://127.0.0.1:5010/pop?type=https
|
获取所有代理
1
| curl http://127.0.0.1:5010/all
|
1
| curl http://127.0.0.1:5010/all?type=https
|
获取所有代理总数
1
| curl http://127.0.0.1:5010/count
|
删除代理
1
| curl http://127.0.0.1:5010/delete?proxy=<ip>:<port>
|
完成
参考文献
知乎——CDA数据分析师