【发布时间】:2017-09-04 18:46:18
【问题描述】:
更新的代码 - 我正在使用此代码发送请求:
headers = {
"Host": "www.roblox.com",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0",
"Accept": "application/json, text/plain, */*",
"Accept-Language": "en-US;q=0.7,en;q=0.3",
"Referer": "https://www.roblox.com/users/12345/profile",
"Content-Type": "application/json;charset=utf-8",
"X-CSRF-TOKEN": "some-xsrf-token",
"Content-Length": "27",
"DNT": "1",
"Connection": "close"
}
data = {"targetUserId":"56789"}
url = "http://www.roblox.com/user/follow"
r = requests.post(url, headers=headers, data=data, cookies={"name":"value"})
响应(使用 r.text):
{"isValid":false,"data":null,"error":""}
请求本身是有效的,我使用 burp 发送它并且它有效:
POST /user/follow HTTP/1.1
Host: www.roblox.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: application/json, text/plain, */*
Accept-Language: pl,en-US;q=0.7,en;q=0.3
Referer: https://www.roblox.com/users/12345/profile
Content-Type: application/json;charset=utf-8
X-CSRF-TOKEN: Ab1/2cde3fGH
Content-Length: 27
Cookie: some-cookie=;
DNT: 1
Connection: close
{"targetUser":"56789"}
【问题讨论】:
-
当我询问更多信息时,我预计您正在使用的网站,所以我可以自己测试它。请把它添加到问题中?
-
@AshwiniChaudhary 这与很多地方所说的相反。我知道可以按照您提到的方式发送 cookie,但这也应该有效。
-
@apoorlydrawnape 将链接更改为真实网站。
-
谢谢。我会测试它。罗布洛克斯?最近他们一直在使用验证码加强安全性。
-
@AshwiniChaudhary 我想你可能是对的 - stackoverflow.com/questions/7164679/…
标签: python python-3.x http-post