欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python基于scrapy采集數(shù)據(jù)時使用代理服務器的方法

 更新時間:2015年04月16日 11:27:08   作者:pythoner  
這篇文章主要介紹了Python基于scrapy采集數(shù)據(jù)時使用代理服務器的方法,涉及Python使用代理服務器的技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了Python基于scrapy采集數(shù)據(jù)時使用代理服務器的方法。分享給大家供大家參考。具體如下:

# To authenticate the proxy, 
#you must set the Proxy-Authorization header. 
#You *cannot* use the form http://user:pass@proxy:port 
#in request.meta['proxy']
import base64
proxy_ip_port = "123.456.789.10:8888"
proxy_user_pass = "awesome:dude"
request = Request(url, callback=self.parse)
# Set the location of the proxy
request.meta['proxy'] = "http://%s" % proxy_ip_port
# setup basic authentication for the proxy
encoded_user_pass=base64.encodestring(proxy_user_pass)
request.headers['Proxy-Authorization'] = 'Basic ' + encoded_user_pass

希望本文所述對大家的python程序設計有所幫助。

相關文章

最新評論