syntax error, expect {, actual error, pos 0

期望是{,实际上是error

抓取目标:站点成功登录的Cookie

站点环境

Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest

接收数据类型为json类型,传参类型为urlcoded编码格式为UTF-8

content-type的取值是告诉服务端,要传递过去的内容类型。

当action为get时候,浏览器用x-www-form-urlencoded的编码方式把form数据转换成一个字串(name1=value1&name2=value2...),然后把这个字串append到url后面,用?分割,加载这个新的url。 当action为post时候,浏览器把form数据封装到http body中,然后发送到server。

检查站点 Formdata 数据类型如下

json: {"account_no":"xxx","account_pw":"***","token_code":"验证码"}

报错代码:

data = {'json':{"account_no": "xxx", "account_pw": "***", "token_code": f"{res}"}}
texts = requests.post(
    url="http://www.xxx.com/login",
    data=data,
    headers=header
)
cookie={}
for i in texts.cookies:
    cookie[i.name] = i.value
print(cookie)

提交表单后返回的页面信息

{"msg":[{"msg":"syntax error, expect {, actual error, pos 0"}],"msgType":"error"}

对此,尝试转换Formdata数据类型、尝试转换编码格式。

 

 

 

 

 

 

 

 

Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐