如何将POST请求发送到https而不会导致python3

时间:2017-11-06 05:16:51

标签: python-3.x http ssl post https

这是事情,我一直在尝试从python中向我的大学wifi页面发送POST请求到LOGIN但我收到SSL证书错误。 POST请求在chrome的POSTMAN扩展中正常工作。

以下是当我使用chrome'e调试器查看POST请求时请求的样子

Request URL:https://112.133.253.2:8090/login.xml
Request Method:POST
Status Code:200 OK
Remote Address:112.133.253.2:8090
Referrer Policy:no-referrer-when-downgrade
POST /login.xml HTTP/1.1
Host: 112.133.253.2:8090
Connection: keep-alive
Content-Length: 72
Origin: https://112.133.253.2:8090
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: */*
Referer: https://112.133.253.2:8090/httpclient.html
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

我发现问题在于在帖子请求网址中指定“http”,该网址应为 https

但是当我使用https时,我得到了python的SSL证书错误。

我试过给verify=False参数没有运气。我也尝试过这样的证书路径: -

    resp = S.post("https://112.133.253.2:8090/login.xml" ,
 data = data  ,
 verify = "/etc/ssl/certs/ca-certificates.crt") ;

但没有任何作用。

邮递员的延期如何在不给出SSL证书错误的情况下工作?如何解决此问题以从Python本身发送请求?

1 个答案:

答案 0 :(得分:0)

尝试禁用以下警告:

from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

希望它有所帮助。