简体   繁体   中英

Python - urllib.open - "SSL: CERTIFICATE_VERIFY_FAILED" Error

I want to download a file from a website but when i use urlopen i have an error:

url= 'https://dpdhl.com/content/dam/dpdhl/en/media-center/investors/documents/statbooks/2021/DPDHL-Statbook-Q4-FY-2020.xlsx'

urll = urllib.request.urlopen(url)

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificate is not valid for 'dpdhl.com'. (_ssl.c:1123)>

Someone can help me. Best regards

This is not an error in your code. HTTPS uses SSL (Secure Socket Layer) and the target website provided an invalid certificate. Change https to http and it will work, but you lose the security of SSL.

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