标签:proxy lis apple ons chrome install div agent www
# -*- coding: utf-8 -*- __author__ = ‘t_lishu‘ from urllib import request def use_proxy_ip(): url = ‘https://www.baidu.com/‘ proxy = {‘http‘: "10.41.82.82:8080"} # 创建ProxyHandler proxy_support = request.ProxyHandler(proxy) # 创建Opener opener = request.build_opener(proxy_support) # 添加User Angent opener.addheaders = [(‘user-agent‘, ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36‘)] # 安装OPener request.install_opener(opener) response = request.urlopen(url) html = response.read() print(html) if __name__ == ‘__main__‘: use_proxy_ip()
标签:proxy lis apple ons chrome install div agent www
原文地址:https://www.cnblogs.com/tuijin/p/9928018.html