stkvtflw
stkvtflw

Reputation: 13587

Proxy server doesn't change public IP with Python Requests

I'm running this script:

import requests

proxyDict = {"http"  : 'http://81.93.73.28:8081'}

r = requests.get('http://ipinfo.io/ip', proxies=proxyDict)
r.status_code
r.headers['content-type']

r.encoding

print(r.text)

I've tried my own proxy server as well as several public servers. It still prints my current ip. What am I doing wrong?

Upvotes: 0

Views: 330

Answers (1)

Aleksander Ikleiw
Aleksander Ikleiw

Reputation: 2685

Problems seem to be with proxy. I tried the random, free one with that code. Also, your code got a few issues. You are calling attributes without usage - they are no need. Try with that code and proxy, for me, it worked.

proxyDict = {"http"  : 'http://162.14.18.11:80'}

r = requests.get('http://ipinfo.io/ip', proxies=proxyDict, )
print(r.status_code)

print(r.text)

Upvotes: 1

Related Questions