Reputation:
import requests
proxies = {'http': '203.92.33.87:80'}
# Creating the session and setting up the proxies.
s = requests.Session()
s.proxies = proxies
# Making the HTTP request through the created session.
r = s.get('https://www.trackip.net/ip')
# Check if the proxy was indeed used (the text should contain the proxy IP).
print(r.text)
In above code I am expecting that print will print 203.92.33.87. But it is printing my real public IP.
Upvotes: 1
Views: 122
Reputation: 168616
In your proxies
dictionary, you only specify a proxy for protocol http
. But in your s.get()
, you specificy protocol https
. Since there is no https
key in your dictionary, no proxy is used.
If 203.92.33.87:80
is, in fact, an https proxy, then change the proxies
dictionary to reflect that. On the other hand, if it is an http proxy, then change s.get()
to s.get('http://...')
.
Also, I believe you've incorrectly specified the proxy URL. According to the documentation:
Note that proxy URLs must include the scheme
Upvotes: 2