Error when opening HTTPS using Urllib2.urlopen: urllib2.urlerror: <urlopen error [ssl:certificate_verify_failed] Certificate Verify failed (_ssl.c:590) >
This error occurs because the HTTPS certificate for the target Web site was not purchased at the certificate issuing authority.
The cause of the problem is "ssl:certificate_verify_failed".
The Python upgrade to 2.7.9 introduces a new feature that validates an SSL certificate once you open an HTTPS link using Urllib.urlopen.
A urllib2 is thrown when the target site uses a self-signed certificate. Urlerror: Error message, detailed information can be viewed here (https://www.python.org/dev/peps/pep-0476/).
Solution:
1. Create an unauthenticated context using SSL and pass in the context parameter in Urlopen
Import SSL
Import Urllib2
context = Ssl._create_unverified_context ()
Print Urllib2.urlopen ("https://www.111cn.net/", Context=context). Read ()
2. Turn off certificate validation when SSL is imported
Import SSL
Import Urllib2
Ssl._create_default_https_context = Ssl._create_unverified_context
Print Urllib2.urlopen ("https://www.111cn.net/"). Read ()