how to fix beautifulsoup ssl CERTIFICATE_VERIFY_FAILED error

老子叫甜甜 提交于 2019-12-13 09:49:34

问题


Code:

import requests

from bs4 import BeautifulSoup

from urllib.request import Request, urlopen

html = urlopen("https://www.familyeducation.com/baby-names/browse-origin/surname/german")

soup = BeautifulSoup(html)

metadata=soup.find_all('meta')

Error:

urlopen error [SSL: CERTIFICATE_VERIFY_FAILED]


回答1:


For this error check out this answer: urllib and "SSL: CERTIFICATE_VERIFY_FAILED" Error

But you don't need urlopen for html request always. You can also send the request through requests lib. Try this one:

import requests

from bs4 import BeautifulSoup

html = requests.get("https://www.familyeducation.com/baby-names/browse-origin/surname/german")

soup = BeautifulSoup(html.text, "html.parser")

metadata = soup.find_all('meta')


来源:https://stackoverflow.com/questions/55096291/how-to-fix-beautifulsoup-ssl-certificate-verify-failed-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!