简体   繁体   中英

Python: get website source code using urllib2 (ssl problems)

As I mentioned in the title, I want to read the source code of a website. Everything is working fine, but sometimes I get an Error.

Error

urllib2.URLError: <urlopen error [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590)

I know that there is a problem with the ssl certificate, but I don't know how to fix it. I already spent several hours to find a solution to my problem, but until now I was not successful (I have already tried a couple things with the ssl module).

The way I do it:

import urllib2
urllib2.openurl("https://www.website.com")

If there is no way doing this kind of stuff with urllib2 , is there a different module, which you recommend?

It might be happening due to some ssl options that the server requests and urllib2 library doesn't support.

I recommend you to install and use request library as it provides more security packages and options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM