python http请求中post请求参数显示是 Request Payload 是一个列表

问题描述:

今天碰到这个情况,还是记录下在这里插入图片描述
在这里插入图片描述

这种分几种情况, 一种为 : json , 一种为:text

问题解决:

话不多说,直接上

requests 写法:
url = 'https://ggzy.yibin.gov.cn/TrueLoreAjax/TrueLore.Web.WebUI.AjaxHelper,TrueLore.Web.WebUI.ashx'
# data = '["TrueLore.Web.WebUI.WebAjaxService","GetPageZhongBiaoJieGuoGongShi",[0,15,"121",1,true,"zhaoBiao_XiangMu_Name","","OrderType "],null,null]1677745826283'
data = '["TrueLore.Web.WebUI.WebAjaxService","GetPageKBJL",[0,15,"112",1,false,"zhaoBiao_XiangMu_Name","","FBSJ DESC"],null,null]'
headers = {
    "Ajax-method": "AjaxMethodFactory",
}
response = requests.post(url, data=data,  headers=headers)
print(response.text)
txt = response.text
demo = txt.replace('\\r\\n', '').replace('\\', '').replace('"{', '{').replace('}"', '}')
print(demo)
print(type(demo))
print(json.loads(demo))
print(type(json.loads(demo)))

在这里插入图片描述
直接写成data就可以了 , 用字段串 包起来;

scrapy 写法:
                data = r'["TrueLore.Web.WebUI.WebAjaxService","GetPageKBJL",[0,15,"112",1,false,"zhaoBiao_XiangMu_Name","","FBSJ DESC"],null,null]'

            yield scrapy.Request(
                url,
                method='POST',
                callback=self.parse,
                body=data
            )

因为不是json数据,是text的, 直接放在body里面 就可以了
在这里插入图片描述

具体的其他理论的,可以参考这个文章:https://blog.csdn.net/qq_38044574/article/details/83339439;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值