Reputation: 381
I am using python request module for doing HTTP communications. I was using proxy before doing any communication.
import requests
proxy = {'http': 'xxx.xxx.xxx.xxx:port'}
OR
proxy = {'http': 'http://xxx.xxx.xxx.xxx:port'}
OR
proxy = {'http://xxx.xxx.xxx.xxx:port'}
requests.get(url, proxies = proxy)
I am using the above code to add the proxy to the request object. But its seems like proxy is not working. Requests module is taking my network IP and firing the request.
Are there any bug or issue with the request module or any other know issue or is there anything i am missing.
Upvotes: 1
Views: 2005
Reputation: 1520
Documentation says:
If you need to use a proxy, you can configure individual requests with the proxies argument to any request method:
import requests
proxies = {"http": "http://10.10.1.10:3128"}
requests.get("http://example.org", proxies=proxies)
Here proxies["http"] = "http://xxx.xxx.xxx.xxx:port
". It seems you lack http://
Upvotes: 0
Reputation: 6839
Try this:
proxy = {'http': 'http://xxx.xxx.xxx.xxx:port'}
I guess you just missed the http://
in the value of the proxy dict.
Check: http://docs.python-requests.org/en/latest/user/advanced/#proxies
Upvotes: 2