import urllib.request import urllib.parse # 配置代理对象,把协议作为键,主机和端口号为值 handler = urllib.request.ProxyHandler(proxies={'http':'ip:端口'}) url = 'https://www.baidu.com/s?wd=ip' headers = { 'User-Agent': '' } request = urllib.request.Request(url=url,headers=headers) opener = urllib.request.build_opener(handler) response = opener.open(request) content = response.read().decode('utf-8') with open('proxy.html','w',encoding='utf-8') as fp: fp.write(content)
Proxy代理
最新推荐文章于 2022-01-11 20:23:41 发布