1 Star 0 Fork 185

东方甲乙木 / Python爬虫

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
代理测试.py 843 Bytes
一键复制 编辑 原始数据 按行查看 历史
耿直的小爬虫 提交于 2018-09-06 15:50 . Upload 代理测试.py
import requests
from redis import StrictRedis
url='http://www.mzitu.com/'
redis=StrictRedis(host='172.18.200.5', port=6379, db=0, password='')
#c=redis.smembers('可用代理')
headers={
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0'
}
for i in redis.smembers('可用代理'):
t=str(i,encoding='utf8')
test=t .replace('\n','')
proxies={
'http':'http://%s'%test
}
response=requests.get('http://www.baidu.com/',headers=headers,proxies=proxies)
o=1
if response.status_code == 200:
redis.sadd('成功代理',test)
print('当前代理可以使用 ip为:',test,'当前成功为%d'%o,'个')
else:
redis.sadd('失效代理ip',test)
print('失效一个')
Python
1
https://gitee.com/softwyy/python_reptilian.git
git@gitee.com:softwyy/python_reptilian.git
softwyy
python_reptilian
Python爬虫
master

搜索帮助