Connection error with response python module

Viewed 15

I am using the response module of python to download quite some data but I am facing an issue. Before posting my specific case, I have tried with a simpler code to test the issue and I face the same problem. Basically, when running this:

import request

x = requests.get('https://w3schools.com')
print(x.status_code)

following is the error I am facing.

ConnectionError: HTTPSConnectionPool(host='w3schools.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002240C195760>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))

Could anyone guide me on this. I suspect its an issue with my network configuration? I have no experience with network management so I am lost on that.

Thanks

1 Answers

Well, I just found out it is indeed an error with my network, basically missing the proxy info as I am working behind one.

For those looking at this in the future, add your proxy settings manually:

import requests 

proxies = {'http': 'http://your.proxy.com:8080',   
           'https': 'http://your.proxy.com:8080'}

url = 'https://w3schools.com' 

response = requests.post(url, proxies=proxies)

print(response.status_code)

If you get 200 then it is working.

Related