当前位置: 首页 > 工具软件 > proxy-test > 使用案例 >

requests proxy代理设置

轩辕阳焱
2023-12-01
import requests
proxy = {
    "http": "socks5://xx.xx.xx.xx:8080",
    'https': 'socks5h://xx.xx.xx.xx:8080'
}

#proxiy = {
#			'http': 'socks5://user:pass@host:port',
#			'https': 'socks5h://user:pass@host:port'
#			}

url = 'https://www.google.com'
r = requests.get(url, proxies=proxy, verify=False)

print(r.content)

PS:需要安装PySocks库,requests需要升至最新版
pip install PySocks
pip install --upgrade requests

 类似资料: