requests是一个比urllib以及urllib2更好用的模块,API很简单。使用方便,下面是我的一个小例子,使用python的该模块下载某个站点的文件。
import requets proxies = {"http":"http://127.0.0.1:8087", "https":"https://127.0.0.1:8087"} with open('gfwlist.txt','wb') as handle: response=requests.get("http://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt",stream=True,proxies=proxies) for block in response.iter_content(1024): if not block: break handle.write(block)