部分爬虫项目会用到IP池,免不了要使用tinyproxy
安装:
apt install tinyproxy
配置:
vim /etc/tinyproxy.conf
修改其中的两项配置,首先, 将这一行注释掉如果使用的是云服务器,需要添加一下安全组规则:
测试tinyproxy是否可用 :
在项目下进入 scrapy shell (运行scrapy shell时 需切换到 项目.cfg 配置同级目录下
在shell里运行: import requests
requests.get('http://httpbin.org/ip',proxies={'http':'http://主机:端口'}).json()
返回结果为你的代理IP则正常