urlopen错误[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败:无法获取本地发行者证书(_ssl.c:1056)

时间:2019-11-08 10:45:04

标签: python web-scraping ssl-certificate urllib

学习抓取网站。现在为“ https://www.localharvest.org/。尝试urlopen,但给出上述错误。 Windows 10 64-64位,Python 3.7.1

from urllib.request import urlopen
from bs4 import BeautifulSoup as soup

url = 'https://www.localharvest.org/'
response = urlopen(url)

2 个答案:

答案 0 :(得分:0)

通过PIP-bash pip install --upgrade认证

timon.web: Fixing CERTIFICATE_VERIFY_FAILED error

答案 1 :(得分:0)

在 Ubuntu 20.04 中,这对我有帮助

sudo update-ca-certificates --fresh
export SSL_CERT_DIR=/etc/ssl/certs