gpt4 book ai didi

python - 请求发布带有字典格式错误的数据

转载 作者:行者123 更新时间:2023-12-04 16:21:08 30 4
gpt4 key购买 nike

将发送到服务器的表单数据如下所示:
Formdata

我没有把它正确地发布到服务器上。我试过这样:

payload = {
"ad_id": ad_id,
"ad_type": "1",
"csrf_token": crsf_token,
"messages": [{'content': 'message to server', 'message_type': 'text'}],
"user_id": "9020446"
}
#
headers = {
"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7",
"Content-Type": "application/json",
"Origin": "https://www.wg-gesucht.de",
"Referer": f"https://www.wg-gesucht.de/nachricht-senden.html?message_ad_id={ad_id}"
}
res = browser.post('https://www.wg-gesucht.de/ajax/api/Smp/api.php?action=conversations', payload, headers=headers)

我也这样试过:
"messages": ['message to server']

但我总是收到 401 错误。

如果有人可以帮助我,那就太好了。

此致!

最佳答案

您可以在 python 中使用“请求”库

import requests
payload = {
"ad_id": ad_id,
"ad_type": "1",
"csrf_token": crsf_token,
"messages": [{'content': 'message to server', 'message_type': 'text'}],
"user_id": "9020446"
}
#
headers = {
"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7",
"Content-Type": "application/json",
"Origin": "https://www.wg-gesucht.de",
"Referer": f"https://www.wg-gesucht.de/nachricht-senden.html?message_ad_id={ad_id}"
}
res = requests.post('https://www.wg-gesucht.de/ajax/api/Smp/api.php?action=conversations', data=payload, headers=headers)

关于python - 请求发布带有字典格式错误的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58244079/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com