python羊 发表于 2020-5-23 18:01:35

网页POST, 用form表单提交,报错报了一堆

为什么我用自己写的表单提交,却报错了。

原代码:
——————————————————————————————————————————————
import requests

url = 'https://my.hrdantwerp.com/?'
data = {'id':' 34','record_number':' 180000008959','L':' '}
r =requests.post(url,data)

print(r.text)
——————————————————————————————————————

suchocolate 发表于 2020-5-23 18:01:36

url = 'https://my.hrdantwerp.com/?'
headers = {'user-agnet': 'firefox'}
data = {'id': '34', 'record_number': '180000008959', 'L': ''}
r = requests.post(url, headers=headers, data=data, verify=False)
print(r.text)

_2_ 发表于 2020-5-23 18:06:31

……说实话没看懂你的意思

Twilight6 发表于 2020-5-23 18:07:18

哥 ,报错的话行不行把报错内容先发出来,这才是最主要的啊我们根据报错内容看你上面代码的问题 。。。晕

Twilight6 发表于 2020-5-23 19:26:51

刚刚试着运行了下你的代码,返回的错误是:
requests.exceptions.SSLError
这说明是证书错误,你post请求里面增加一个 verify = False 的选项,跳过证书验证即可
r =requests.post(url,data,verify = False)

xiaosi4081 发表于 2020-5-23 19:29:33

Twilight6 发表于 2020-5-23 19:26
刚刚试着运行了下你的代码,返回的错误是:

这说明是证书错误,你post请求里面增加一个 verify = False...

    InsecureRequestWarning,
InsecureRequestWarning: Unverified HTTPS request is being made to host 'my.hrdantwerp.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

Twilight6 发表于 2020-5-23 19:36:49

xiaosi4081 发表于 2020-5-23 19:29
InsecureRequestWarning,
InsecureRequestWarning: Unverified HTTPS request is being made to hos ...

运行之后要稍等15秒左右,这个网站返回数据太慢了

xiaosi4081 发表于 2020-5-23 19:38:53

Twilight6 发表于 2020-5-23 19:36
运行之后要稍等15秒左右,这个网站返回数据太慢了

怎么做?

Twilight6 发表于 2020-5-23 19:42:56

xiaosi4081 发表于 2020-5-23 19:38
怎么做?

运行之后等待即可,红色的字只是警告

suchocolate 发表于 2020-5-23 23:52:04

xiaosi4081 发表于 2020-5-23 19:29
InsecureRequestWarning,
InsecureRequestWarning: Unverified HTTPS request is being made to hos ...

提问的是小号?

xiaosi4081 发表于 2020-5-24 12:00:00

suchocolate 发表于 2020-5-23 23:52
提问的是小号?

????
页: [1]
查看完整版本: 网页POST, 用form表单提交,报错报了一堆