Sometimes, we want to use proxies with the Python ‘Requests’ module.
In this article, we’ll look at how to use proxies with the Python ‘Requests’ module.
How to use proxies with the Python ‘Requests’ module?
To use proxies with the Python ‘Requests’ module, we can set the proxies
argument when we make the request.
For instance, we write
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 = {"http": http_proxy, "https": https_proxy, "ftp": ftp_proxy}
r = requests.get(url, headers=headers, proxies=proxies)
to call requests.get
with the url
to make the requests to and the proxies
argument set to the proxies
dict that has the proxy URLs for http, https, and ftp requests.
Conclusion
To use proxies with the Python ‘Requests’ module, we can set the proxies
argument when we make the request.