Can`t connect to a proxy using requests Python

1.9k Views Asked by At

I am trying to connect to a http server using python but after I send a get request to: https://httpbin.org/ip

I get my normal ip public like if I wasnt using a proxy.

We are going to suppose that my public ip without using proxy is: 10.10.10.10 This is my code:

proxies ={
        
    "http":"http://103.103.175.253:3128"
}
get = requests.get("https://httpbin.org/ip", proxies = proxies)
soup = bs(get.text,'html.parser')
print(soup.prettify())
print(get.status_code, get.reason)

and I get:

{
  "origin": "10.10.10.10"
}

200 OK

And I should recieve "origin":"103.103.175.253"

CAN SOMEONE HELP ME PLEASE????

1

There are 1 best solutions below

0
On BEST ANSWER

You're connecting to https:// site, but you've only specified http proxy.

You can use http:// protocol, or specify another https proxy. For example:

proxies = {
    "http": "http://103.103.175.253:3128",
}

get = requests.get("http://httpbin.org/ip", proxies=proxies)  # <-- connect to http://
soup = BeautifulSoup(get.text, "html.parser")
print(soup.prettify())
print(get.status_code, get.reason)

Prints:

{
  "origin": "103.103.175.253"
}

200 OK