0

My code is like this:

import requests
proxies = {'http':'ip:port'}
r = requests.get('http://example.com', proxies = proxies)

And when I run this code in a PC with a unique ip address, it works fine, BUT when I run this code in a PC behind a router, it cannot get any response. After I check the proxy server, I find out that the connection was not in the log of the proxy server.

I cannot figure this out, please help, thanks a lot.

With @MilkeyMouse's help, I changed my code to:

proxies = {'http':'http://ip:port'}

But it still doesn't work.

zhoujz10
  • 1
  • 2

1 Answers1

0

Since Requests 2.0.0, you'll need to add a scheme to the proxy. See the section in the Requests docs:

import requests

proxies = {
  "http": "http://10.10.1.10:3128",
  "https": "http://10.10.1.10:1080",
}

requests.get("http://example.org", proxies=proxies)

Note the http:// before the proxy URL.

MilkeyMouse
  • 581
  • 4
  • 11