`
hzy3774
  • 浏览: 984934 次
  • 性别: Icon_minigender_1
  • 来自: 珠海
社区版块
存档分类
最新评论

Python网络库requests使用代理

阅读更多

有时候我们在使用python爬虫的时候对某些特殊URL地址访问时需要通过代理的方式,使用requests库可以方便的通过参数支持:

import requests

proxies = {'http': 'http://gfw.xxx.com:8118', 'https': 'http://gfw.xxx.com:8118'}

content = requests.get("https://play.google.com/store", proxies=proxies)
print content

content = requests.get("http://www.google.com", proxies=proxies)
print content

 

设置代理方便多了。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics