大佬教程收集整理的这篇文章主要介绍了Scraping: SSL: CERTIFICATE_VERIFY_FAILED error for http://en.wikipedia.org,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
从前,我偶然发现了这个问题。如果您使用的是macOS,请转至Macintosh HD>应用程序> python3.6文件夹(或您使用的任何Python版本)>双击“ Install Certificates.command”文件。
我正在练习“使用Python进行网页搜刮”中的代码,但始终遇到此证书问题:
from urllib.request import urlopen
from bs4 import BeautifulSoup
import re
pages = set()
def getLinks(pageUrl):
global pages
html = urlopen("http://en.wikipedia.org"+pageUrl)
bsObj = BeautifulSoup(html)
for link in bsObj.findAll("a",href=re.compile("^(/wiki/)")):
if 'href' in link.attrs:
if link.attrs['href'] not in pages:
#We have encountered a new page
newPage = link.attrs['href']
print(newPagE)
pages.add(newPagE)
getLinks(newPagE)
getLinks("")
@H_801_12@
错误是:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py",line 1319,in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1049)>
@H_801_12@
顺便说一句,我也在练习scrapy,但是不断出现问题:找不到命令:scrapy
以上是大佬教程为你收集整理的Scraping: SSL: CERTIFICATE_VERIFY_FAILED error for http://en.wikipedia.org全部内容,希望文章能够帮你解决Scraping: SSL: CERTIFICATE_VERIFY_FAILED error for http://en.wikipedia.org所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。