[Python]使用代理IP隐藏真实地址

[Python]使用代理IP隐藏真实地址

仅供学习使用,请勿用于违法用途
使用时将对应IP和端口改掉即可

#设置代理地址(无加密)

import requests

#定义IP和端口
Proxy_IP = ""
Proxy_Port = ""

proxy = {
    "http": "http://"+Proxy_IP+":"+Proxy_Port,
    "https": "http://"+Proxy_IP+":"+Proxy_Port
}

#定义要访问的地址
url = ""

s = requests.session()
html = s.get(url,proxies=proxy)
print(html)
#设置代理地址(加密)

#定义IP和端口
Proxy_IP = ""
Proxy_Port = ""

#定义用户名和密码
username = ""
passwd = ""

proxy = {
    "http": "http://"+username+":"+passwd+"@"+Proxy_IP+":"+Proxy_Port,
    "https": "http://"+username+":"+passwd+"@"+Proxy_IP+":"+Proxy_Port
}

#定义要访问的地址
url = ""

s = requests.session()
html = s.get(url,proxies=proxy)
print(html)