相关疑难解决方法(0)

抛出SSLError的Python请求

我正在编写一个涉及CAS,jspring安全检查,重定向等的简单脚本.我想使用Kenneth Reitz的python请求,因为它是一项很棒的工作!但是,CAS需要通过SSL进行验证,因此我必须先通过该步骤.我不知道Python的要求是什么?这个SSL证书应该驻留在哪里?

Traceback (most recent call last):
  File "./test.py", line 24, in <module>
  response = requests.get(url1, headers=headers)
  File "build/bdist.linux-x86_64/egg/requests/api.py", line 52, in get
  File "build/bdist.linux-x86_64/egg/requests/api.py", line 40, in request
  File "build/bdist.linux-x86_64/egg/requests/sessions.py", line 209, in request 
  File "build/bdist.linux-x86_64/egg/requests/models.py", line 624, in send
  File "build/bdist.linux-x86_64/egg/requests/models.py", line 300, in _build_response
  File "build/bdist.linux-x86_64/egg/requests/models.py", line 611, in send
requests.exceptions.SSLError: [Errno 1] _ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Run Code Online (Sandbox Code Playgroud)

python ssl urllib3 python-requests

309
推荐指数
15
解决办法
54万
查看次数

来自url的Pandas read_csv

我正在使用Python 3.4和IPython,并具有以下代码.我无法从给定的URL读取csv文件:

import pandas as pd
import requests

url="https://github.com/cs109/2014_data/blob/master/countries.csv"
s=requests.get(url).content
c=pd.read_csv(s)
Run Code Online (Sandbox Code Playgroud)

我有以下错误

"预期的文件路径名或类文件对象,得到类型"

我怎样才能解决这个问题?

python csv request pandas

106
推荐指数
5
解决办法
11万
查看次数

在python中使用请求时无法获取本地颁发者证书

这是我的代码

import requests;
url='that website';
headers={
  'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
  'Accept-Language':'zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7',
  'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'
};
r = requests.get(url,headers=headers);
print(r);
print(r.status_code);
Run Code Online (Sandbox Code Playgroud)

然后它遇到了这个:

requests.exceptions.SSLError:

HTTPSConnectionPool(host='www.xxxxxx.com', port=44 3):

url: xxxxxxxx 超出最大重试次数(由 SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED]

证书验证失败:无法获得本地颁发者证书 (_ssl.c:1045)')))

我该怎么办?

python python-requests

47
推荐指数
6
解决办法
10万
查看次数

刮刮: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万
查看次数

Mac OS 上的诗歌安装失败,显示“should_use_symlinks”

我正在尝试使用以下命令安装诗歌

curl -sSL https://install.python-poetry.org | python3 -
Run Code Online (Sandbox Code Playgroud)

但它失败了,但有以下例外:

例外:此版本的 python 无法在不使用符号链接的情况下创建 venvs

下面是详细说明错误的文本

Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

/Users/DaftaryG/.local/bin

You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.

Installing Poetry (1.2.1): Creating environment
Traceback (most recent call last): …
Run Code Online (Sandbox Code Playgroud)

python macos installation python-poetry

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

openssl,python请求错误:"证书验证失败"

如果我从开发框中运行以下命令:

$ openssl s_client -connect github.com:443
Run Code Online (Sandbox Code Playgroud)

我得到以下最后一行输出:

Verify return code: 20 (unable to get local issuer certificate)
Run Code Online (Sandbox Code Playgroud)

如果我尝试使用请求执行此操作,则会收到另一个失败请求:

>>> import requests
>>> r = requests.get('https://github.com/', verify=True)
Run Code Online (Sandbox Code Playgroud)

提出异常:

SSLError: [Errno 1] _ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Run Code Online (Sandbox Code Playgroud)

我还可以使用verify标志运行第一个命令并获得类似的输出:

$ openssl s_client -connect github.com:443 -verify 9
...
Verify return code: 27 (certificate not trusted)
Run Code Online (Sandbox Code Playgroud)

基本上这告诉我证书有问题.我可以使用这两种方法指定一个特定的证书,它将起作用:

$ openssl s_client -connect github.com:443 -CAfile /etc/ssl/certs/DigiCert_High_Assurance_EV_Root_CA.pem -verify 9
...
Verify return code: 0 (ok)
Run Code Online (Sandbox Code Playgroud)

和:

>>> r = requests.get('https://github.com/', verify='/etc/ssl/certs/DigiCert...pem')
<Response [200]>
Run Code Online (Sandbox Code Playgroud)

那么,就我的问题而言,这究竟是什么问题?请求/ openssl不应该知道在哪里可以找到有效的证书吗?

其他信息:

  • Python的== …

python openssl python-requests

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

Python 3 和 Slack 客户端:ssl.SSLCertVerificationError

我正在尝试在 python 3.8 中访问 Slack,但我无法通过第一步。这是我的代码:

import slack

slack_token="xoxp-*******-*******-*******-*******"
client = slack.WebClient(slack_token)

client.chat_postMessage(
    channel="XXXXXXXXXX",
    text="Hello from your app! :tada:"
)

print('hello')

Run Code Online (Sandbox Code Playgroud)

这是错误:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/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 1046, in create_connection
    transport, protocol = await self._create_connection_transport(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1076, in _create_connection_transport
    await waiter
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py", line 529, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py", line 189, in feed_ssldata
    self._sslobj.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line …
Run Code Online (Sandbox Code Playgroud)

python-3.x slack

5
推荐指数
2
解决办法
1901
查看次数