标签:data header open com read from ica pre test
# coding=utf-8 # urllib_get_file=urllib.request.urlretrieve(url=None,filename="test.zip") # basic usage of urllib from urllib import request url = "https://www.cnblogs.com/SunshineKimi/" msg = request.Request(url) # msg.add_header("1",2) # msg.set_proxy() rep = request.urlopen(msg) print(rep.read()) # how to use proxy to request in urllib proxies = {"http": "user:passwd@ip:port"} # buy proxy proxy = {"http": "111.79.44.217:9999"} # free proxy proxy_handler = request.ProxyHandler(proxy) # there also exist HttpHandler() basic handler opener = request.build_opener(proxy_handler) response = opener.open(url, data=None) print(response.headers) # auth by proxy passwd_manager=request.HTTPPasswordMgrWithDefaultRealm() passwd_manager.add_password(realm=None,uri=proxy,user="user",passwd="password") buy_auth_handler=request.ProxyBasicAuthHandler(passwd_manager) opener_auth=request.build_opener(buy_auth_handler) response_auth=opener_auth.open(url=None,data=None).read() print(response_auth)
标签:data header open com read from ica pre test
原文地址:https://www.cnblogs.com/SunshineKimi/p/12301974.html