如何修复Beautifulsoup SSL CERTIFICATE_VERIFY_FAILED错误 [英] how to fix beautifulsoup ssl CERTIFICATE_VERIFY_FAILED error
本文介绍了如何修复Beautifulsoup SSL CERTIFICATE_VERIFY_FAILED错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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')
错误:
urlopen错误[SSL:CERTIFICATE_VERIFY_FAILED]
urlopen error [SSL: CERTIFICATE_VERIFY_FAILED]
推荐答案
对于此错误,请查看以下答案: urllib和"SSL:CERTIFICATE_VERIFY_FAILED";错误
For this error check out this answer: urllib and "SSL: CERTIFICATE_VERIFY_FAILED" Error
但是您不必总是将urlopen
用于html request
.您也可以通过requests
lib发送请求.试试这个:
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')
这篇关于如何修复Beautifulsoup SSL CERTIFICATE_VERIFY_FAILED错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文