1, If you want to proxy the request:
ximport requests
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36',
}
url = 'https://www.google.com'
# url = 'https://www.baidu.com'
proxy = '127.0.0.1:10808'
proxies = {
'http': 'socks5://' + proxy,
'https': 'socks5://' + proxy
}
data = requests.get(url,headers=headers, proxies=proxies ,timeout=2)
print(data.text)
10808 is the port in v2ray, check the software settings to get that.
2, If you want to proxy your whole console, typing:
xset http_proxy=socks5://127.0.0.1:10808
set https_proxy=socks5://127.0.0.1:10808
3, If you want to proxy a script:
ximport os
os.environ['HTTP_PROXY'] = 'socks5://127.0.0.1:10808'
os.environ['HTTPS_PROXY'] = 'socks5://127.0.0.1:10808'