目前情况,通过源 URL 得到 ajax,这个 ajax 在英文关键词情况下能请求到数据,但中文关键词情况无法返回值 初步判断是 encode 编码问题,但常用的几个都试了均不行,求助,感谢
Ajax: http://ggzyjy.abazhou.gov.cn/TrueLoreAjax/TrueLore.Web.WebUI.AjaxHelper,TrueLore.Web.WebUI.ashx
payload:["TrueLore.Web.WebUI.WebAjaxService","SearchByCondition",[0,15,"查询关键词","",200,670,190,410,3,"","","Fbqssj DESC"],None,None]')
''' #python
import requests
import json
url = "http://ggzyjy.abazhou.gov.cn/TrueLoreAjax/TrueLore.Web.WebUI.AjaxHelper,TrueLore.Web.WebUI.ashx"
data = ["TrueLore.Web.WebUI.WebAjaxService","SearchByCondition",[0,15,"\xe5\x85\xb3\xe9\x94\xae\xe8\xaf\x8d","",200,670,190,410,3,"","","Fbqssj DESC"],None,None]
headers = {
'Ajax-method': 'AjaxMethodFactory', # 这个很重要
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3738.0 Safari/537.36 Edg/75.0.107.0'
}
html = requests.post(url, headers=headers, data=json.dumps(data))
'''
1
ila 2020-11-11 22:34:07 +08:00 via Android
eval 或 exec
|
2
ticotic 2020-11-12 02:36:43 +08:00
dumps 把"\xe5\x85\xb3\xe9\x94\xae\xe8\xaf\x8d"当成 str 转义了
|
3
sujin190 2020-11-12 18:22:37 +08:00 1
要用 Unicode 字符串啊,然后可以试试这样 json.dumps(result, ensure_ascii=False).encode("utf-8"),基本就和浏览器一致了,不加 ensure_ascii 在 encode 中文会变成\u 转义输出,似乎对方不支持处理\u 转义,而且似乎这个 json 后面还应该有个时间戳啊,注意看
|