洪水 发表于 2022-1-7 22:18:27

python用post一直<Response [403]>

想登录这个网站
https://www.jiandaoyun.com/signin
我写的:
import requests
url = 'https://www.jiandaoyun.com/signin'
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '
                         '(KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36'
         }
date = {'username': '+86-1783840xxxx'
      , 'password': 'xxxxxx'
      }
s = requests.Session()
r = s.post(url=url, data=date, headers=headers)
print(r)

陈公子的话 发表于 2022-1-7 22:18:28

洪水 发表于 2022-1-10 22:22
搜了好多东西还是不会,哥哥能给个思路吗?谢谢了

head里面那几个数据补上数据从源码去获取   ck和那个token很重要post不是直接request.post那么简单的。。

陈公子的话 发表于 2022-1-8 10:08:16

header里面的x-csrf-token x-request-id cookie处理一下

洪水 发表于 2022-1-8 10:43:56

陈公子的话 发表于 2022-1-8 10:08
header里面的x-csrf-token x-request-id cookie处理一下

怎么处理

洪水 发表于 2022-1-10 22:22:45

陈公子的话 发表于 2022-1-8 10:08
header里面的x-csrf-token x-request-id cookie处理一下

搜了好多东西还是不会,哥哥能给个思路吗?谢谢了

Ne-21 发表于 2022-1-10 22:39:57

不会处理的话,就不用requests了,直接用selenium。

洪水 发表于 2022-1-11 18:02:00

陈公子的话 发表于 2022-1-11 08:53
head里面那几个数据补上数据从源码去获取   ck和那个token很重要post不是直接request.post那么简单的。 ...

谢谢gg,已经解决了。我先用get和正则表达式从网页源码提取了token,然后再用这个token去post就response 200了。
页: [1]
查看完整版本: python用post一直<Response [403]>