通过代理ip,爬取百度信息
import urllib.request
#构建一个Handler处理器,传入一个代理ip
httpSwitch=urllib.request.ProxyHandler({"http":"120.232.175.244:80"})
#构建一个opene对象
openr=urllib.request.build_opener(httpSwitch)
req=urllib.request.Request("http://www.baidu.com/")
text=openr.open(req)
print(text.read())
浙公网安备 33010602011771号