我将从提供RESTful JSON API的ABB G13网关中检索一些信息.API由网关通过https端点托管.基本认证机制用于认证.但是,所有流量都通过SSL层.
在linux上使用命令:
curl -s -k -X GET -u user:password https://host/meters/a_serial/power
Run Code Online (Sandbox Code Playgroud)
一切顺利!
我正在尝试使用Requests 2.8.1在Python 2.7.10中为Windows编写脚本,并使用以下代码:
import requests
requests.get('https://host/meters/a_serial/power', auth=('user', 'password'))
Run Code Online (Sandbox Code Playgroud)
我有这个错误:
Traceback (most recent call last):
File "C:/Users/mzilio/PycharmProjects/pwrgtw/test.py", line 20, in <module>
requests.get('https://host/meters/a_serial/power', auth=('user', 'password'))
File "C:\Python27\lib\site-packages\requests\api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File …Run Code Online (Sandbox Code Playgroud)