有时候我们在使用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
设置代理方便多了。