Proxies
suggest changeEach request POST operation can be configured to use network proxies.
HTTP/S Proxies
from requests import post
proxies = {
'http': 'http://192.168.0.128:3128',
'https': 'http://192.168.0.127:1080',
}
foo = requests.post('http://httpbin.org/post', proxies=proxies)
The fragment imports post, then calls requests.post. requests is not defined. HTTP Basic Authentication can be provided in this manner:
proxies = {'http': 'http://user:pass@192.168.0.128:312'}
foo = requests.post('http://httpbin.org/post', proxies=proxies)
SOCKS Proxies
The use of SOCKS proxies requires the extra requests[socks]. Once that is installed, SOCKS proxies are set in the same proxies dictionary:
proxies = {
'http': 'socks5://user:pass@host:port',
'https': 'socks5://user:pass@host:port'
}
foo = requests.post('http://httpbin.org/post', proxies=proxies)
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents