If your code is running behind a proxy and you know the end point, you can set this information in your code.
requests
accepts a proxies
parameter. This should be a dictionary that maps protocol to the proxy URL.
proxies = {
'http': 'http://proxy.example.com:8080',
'https': 'http://secureproxy.example.com:8090',
}
Notice that in the dictionary we have defined the proxy URL for two separate protocols: HTTP and HTTPS. Each maps to an individual URL and port. This does not mean that the two can't be the same, though. This is also acceptable:
proxies = {
'http': 'http://secureproxy.example.com:8090',
'https': 'http://secureproxy.example.com:8090',
}
Once your dictionary is defined, you pass it as a parameter.
requests.get('http://example.org', proxies=proxies)