python 访问https链接时错误排查

1. 遇到这种错误有可能是机器无外网权限造成的。

  requests.exceptions.ConnectionError: HTTPSConnectionPool(host='', port=443): Max retries exceeded with url: /s/savecomtajax (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f972f48bf90>: Failed to establish a new connection: [Errno 110] Connection timed out',))

2.  requests 发https 请求时,需要忽略证书的验证, 需要注意如下点。

requests.packages.urllib3.disable_warnings()
def request_ajax_url(login_url,login_body, headers):
'''发送post请求数据'''
req = requests.post(login_url, data=login_body, headers=headers, verify=False);
return req.text
posted @ 2017-03-30 11:41  技术和能力改变命运  阅读(17085)  评论(0编辑  收藏  举报