hupili / python-for-data-and-media-communication-gitbook

An open source book on Python tailed for communication students with zero background
115 stars 62 forks source link

failed to open url with urllib.request #139

Closed ivywze closed 5 years ago

ivywze commented 5 years ago

Troubleshooting

my environment

my question

I could not open url using urllib.request library

The minimum code (snippet) to reproduce the issue

import urllib.request

with urllib.request.urlopen('http://www.indeed.com/jobs?q=data+scientist&l=') as url:
    source = url.read()

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)>

the efforts you have spent on this issue

I found a slack issue SSL Certification error #334 have same discussion, but I still could not figure it out.

hupili commented 5 years ago

Seems CVA network problem. Do you have the same problem when testing in other places?

ivywze commented 5 years ago

Seems CVA network problem. Do you have the same problem when testing in other places?

Yes, I test at home, the error message is: URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)>

hupili commented 5 years ago

It's Ok at my side. It's likely you are behind firewalls.

ivywze commented 5 years ago

It's Ok at my side. It's likely you are behind firewalls.

So...is there anything I can do to make it run?

hupili commented 5 years ago

Since this is network problem, you need to bypass the walls on the pathways. Using a proxy will help. urllib and requests allows to configure a proxy in the parameters. Depending on your network situation, you may find different proxy providers. Just search "HTTP proxy", "SOCKS proxy", etc

ivywze commented 5 years ago

Since this is network problem, you need to bypass the walls on the pathways. Using a proxy will help. urllib and requests allows to configure a proxy in the parameters. Depending on your network situation, you may find different proxy providers. Just search "HTTP proxy", "SOCKS proxy", etc

Thanks for the pointers, will do accordingly.