Last modified: Jan 10, 2023 By Alexander Williams
Using proxies with python-requests
example
http_proxy = "http://10.10.1.10:3128"
https_proxy = "https://10.10.1.11:1080"
ftp_proxy = "ftp://10.10.1.10:3128"
#proxies_dic
proxies = {
"http" : http_proxy,
"https" : https_proxy,
"ftp" : ftp_proxy
}
r = requests.get(url='your_url', proxies=proxies)
socks4 and socks5
if you want to use socks4, socks5 protocol, you need to install this library
pip install -U requests[socks]
exapmle
http_proxy = "socks5://10.10.1.10:3128"
https_proxy = "socks5://10.10.1.11:1080"
proxies = {
"http" : http_proxy,
"https" : https_proxy,
}
r = requests.get(url='your_url', proxies=proxies)