Reputation: 11
So I am trying to implement a proxy service into my script however, after looking at different solutions, my script won't return the proxy's IP address.
Code:
import requests
http_proxy = "http://181.59.126.156:8080"
proxyDict = {
"http" : http_proxy,
}
r = requests.get("https://api.ipify.org/", proxies=proxyDict)
print(r.text)
This returns my real public IP Address when I need it to return the proxies IP address to confirm the proxy is being used when making the HTTP request.
Ipify is the API I am using for testing purposes.
Any Help would be appreciated - Thanks.
Upvotes: 1
Views: 440
Reputation: 1499
That's because your proxy is routing only HTTP requests while your request is done over HTTPS.
To achieve what you want you will need to set up HTTPS proxy like so:
import requests
https_proxy = "http://181.59.126.156:[https_proxy_port]"
proxyDict = {
"https" : https_proxy,
}
r = requests.get("https://api.ipify.org/", proxies=proxyDict)
print(r.text)
Upvotes: 2