今天有个post请求,还挺少见的。 这个post请求,直接在post请求地址后,加参数。如下:

post请求,直接在地址后加请求参数,并将请求参数 url加密

 

 

 加密前如上所示,用fiddler抓包。加密后的如下:

post请求,直接在地址后加请求参数,并将请求参数 url加密

 

 

 

咨询资料后,post 请求,在地址后加参数。 将data参数用params 接收即可。 用params 接收,直接将参数放置url地址后; 用data接收,参数放置body体

rep = requests.post(url=url,params=data)

代码如下:
url ="http://xx.xx.xx.xxx:xxxxx/token/common/accessToken"
data ={
"clientId": "G7",
"clientSecret": "29p7F89T67",
"grantType": "client_credentials",
"scope": "all",
"userId": "SF20201124"}
rep = requests.post(url=url,params=data)
发现,data参数是在 post请求 url地址后了,但是是正常的,没有转码。
使用:data = urlencode(data),放置rep 之前,发现还是不行。与抓包的不一致,且缺少东西。
再次查询资料后, 解决。发现,转码前,不能直接这么放。
由于,这个接口返回json格式数据。直接返回数据,进行了json()处理
参考代码如下:
url = "http://xx.xx.xx.xxx:xxxxx/token/common/accessToken"
a = {"data":{"clientId": "G7",
"clientSecret": "29p7F89T67",
"grantType": "client_credentials",
"scope": "all",
"userId":"SF20201124"}}
data = urlencode(a)
rep = requests.post(url=url,params=data).json()
print(rep)

与fidder抓包一致。
请求:

post请求,直接在地址后加请求参数,并将请求参数 url加密

 

 且响应正常。

 

 



 

相关文章:

  • 2022-01-13
  • 2021-12-09
  • 2021-08-29
  • 2021-07-07
  • 2021-08-30
  • 2018-01-19
  • 2021-08-09
  • 2021-11-04
猜你喜欢
  • 2021-06-16
  • 2021-05-10
  • 2021-12-27
  • 2021-09-10
  • 2021-12-16
  • 2021-07-05
  • 2021-12-06
  • 2021-11-30
相关资源
相似解决方案