定义代理IP
proxie = {
'http' : 'http://xx.xxx.xxx.xxx:xxxx',
'http' : 'http://xxx.xx.xx.xxx:xxx',
....
}使用代理
response = requests.get(url,proxies=proxies)
如何使用呢?
首先使用 git clone 将源代码拉到你本地
接着在你 clone 下来的文件目录中
安装相关所需的 python 模块:
pip3 install -r requirements.txt
接着就可以运行 run.py 了:
代理池开始运行
* Running on http://0.0.0.0:5555/ (Press CTRL+C to quit)
开始抓取代理
获取器开始执行
Crawling http://www.66ip.cn/1.html 正在抓取 http://www.66ip.cn/1.html 抓取成功 http://www.66ip.cn/1.html 200 成功获取到代理 201.69.7.108:9000 成功获取到代理 111.67.97.58:36251 成功获取到代理 187.32.159.61:51936 成功获取到代理 60.13.42.154:9999 成功获取到代理 106.14.5.129:80 成功获取到代理 222.92.112.66:8080 成功获取到代理 125.26.99.84:60493 ...
运行 run.py 你就可以访问你的代理池了,比如随机获取一个代理 ip 地址:
这样访问之后就会获取到一个代理 ip。