相关疑难解决方法(0)

刮刮:SSL:http://en.wikipedia.org的CERTIFICATE_VERIFY_FAILED错误

我正在练习'Web Scraping with 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("")
Run Code Online (Sandbox Code Playgroud)

错误是:

  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)>
Run Code Online (Sandbox Code Playgroud)

顺便说一句,我也在练习scrapy,但一直都在解决问题:找不到命令:scrapy(我在网上尝试过各种解决方案,但都没有用......真的很令人沮丧)

python beautifulsoup ssl-certificate scrapy web-scraping

37
推荐指数
13
解决办法
4万
查看次数

证书验证失败:无法获取本地颁发者证书

我正在尝试使用python从网络获取数据。我为此导入了urllib.request包,但是在执行时出现错误:

certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)
Run Code Online (Sandbox Code Playgroud)

当我将网址更改为“ http”时-我可以获取数据。但是,我相信,这避免了检查SSL证书。

所以我检查了互联网,找到了一个解决方案:运行 /Applications/Python\ 3.7/Install\ Certificates.command

这解决了我的问题。但是我对SSL之类的东西一无所知。您能否帮助我了解它实际上解决了我的问题。

如果可能,请向我推荐任何有用的资源,以了解有关安全性和证书的信息。我是新来的。

谢谢!

注意:我确实通过链接-openssl,python请求错误:“证书验证失败”

我的问题与链接中的问题不同,因为我想知道在安装certifi软件包或运行Install\ Certificates.command该错误时实际发生了什么。我对证券知之甚少。

python ssl openssl python-3.x

29
推荐指数
14
解决办法
3万
查看次数

SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获得本地颁发者证书 (_ssl.c:1108) Discord/python

我正在使用 Pycharm 和 python 3.8 以及最新版本的不和谐。我尝试运行此脚本但出现此错误。任何人都可以帮忙吗?

import discord

TOKEN = 'xxxxx'

client = discord.Client()

@client.event
async def on_message(message):
    # we do not want the bot to reply to itself
    if message.author == client.user:
        return

    if message.content.startswith('!hello'):
        msg = 'Hello {0.author.mention}'.format(message)
        await client.send_message(message.channel, msg)

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

client.run(TOKEN)
Run Code Online (Sandbox Code Playgroud)

------ 下面的错误------

/Users/mellie/PycharmProjects/Dominations/venv/bin/python /Users/mellie/PycharmProjects/Dominations/Domi.py Traceback(最近一次调用):文件“/Users/mellie/PycharmProjects/Dominations/venv/lib/python3 .8/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa File "/Library/Frameworks/Python.framework /Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1042, in create_connection …

python discord.py

3
推荐指数
2
解决办法
2万
查看次数