无法使用Python请求建立新的连接错误Errno -2名称或服务未知

时间:2018-10-04 15:54:46

标签: python api python-requests

我正在尝试使用Python向API发出请求。我可以通过curl发出请求而没有问题,但是我的Python请求有问题。

为什么要这段代码,

import requests
from requests.auth import HTTPBasicAuth

emailadd = 'user123@example.com'
domain = 'example.com'

spantoken = 'omitted'

def checkUserLicensed(useremail):
     url = ('https://api.spannigbackup.com/v1/users/' + useremail)
     print(url)
     response = requests.get(url, auth=(domain,spantoken))
     print(response)

checkUserLicensed(emailadd)

返回此错误

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.spannigbackup.com', port=443): Max retries exceeded with url: /v1/users/user123@example.com 
(Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f73ca323748>: Failed to establish a new connection: [Errno -2] Name or service not known'))

0 个答案:

没有答案