I'm using the great Requests library in my Python script:
import requests r = requests.get("some-site.com") print r.text
I would like to use socks proxy. But Requests only supports HTTP proxy now.
How can I do that?
To use a proxy in Python, first import the requests package. Next create a proxies dictionary that defines the HTTP and HTTPS connections. This variable should be a dictionary that maps a protocol to the proxy URL. Additionally, make a url variable set to the webpage you're scraping from.
Better performance on P2P platformsSOCKS5 is faster than other proxies because it transfers smaller data packets. Therefore, it offers faster download speeds, which is why many users use it to connect to P2P sharing websites and platforms.
The modern way:
pip install -U requests[socks]
then
import requests resp = requests.get('http://go.to', proxies=dict(http='socks5://user:pass@host:port', https='socks5://user:pass@host:port'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With