我正在制作一个使用cookie登录roblox帐户并删除所有朋友的程序,它似乎确实正确地刮掉了用户ids,并在删除成功后打印出来,但是它实际上并没有删除任何人,我对python并不陌生,我想不出有什么解决办法。
import requests
import time
cookie = input('Enter cookie: ')
req = requests.Session()
req.cookies['.ROBLOSECURITY'] = cookie
try:
userid = req.get('https://www.roblox.com/mobileapi/userinfo').json()['UserID']
except:
input('invalid cookie given')
exit()
print('\nlogged in\n')
friends = req.get(f'https://friends.roblox.com/v1/users/{userid}/friends').json()
friendlist = {}
for friend in friends["data"]:
friendlist[friend["id"]] = friend
for friend in friendlist:
try:
r = req.post(f'https://friends.roblox.com/v1/users/{friend}/unfriend')
print(f'deleted friend - {friend}')
except:
print('error')
time.sleep(999)发布于 2021-11-05 14:42:28
抱歉反应太晚了。我做了这样的事情,以取消跟踪每个人,除了终止用户。
试一试我的脚本,它应该解除每个人的朋友:
import requests,json,time
cookie = "cookie here"
while True:
with requests.session() as session:
session.cookies[".ROBLOSECURITY"] = cookie
header = session.post("https://catalog.roblox.com/")
session.headers["X-CSRF-TOKEN"] = header.headers["X-CSRF-TOKEN"]
session.headers["Origin"] = "https://www.roblox.com/"
session.headers["Referer"] = "https://www.roblox.com/"
user = session.get("https://www.roblox.com/mobileapi/userinfo").json()
friends = session.get("https://friends.roblox.com/v1/users/{0}/friends".format(user["UserID"])).json()
if len(friends["data"]) > 0:
for friend in friends["data"]:
response = session.post("https://friends.roblox.com/v1/users/{0}/unfriend".format(friend["id"])).json()
print(response)
else:
print("everyone has been unfriended")
break

编辑:我看了一下您的脚本,似乎您忘了用X令牌验证会话。
https://stackoverflow.com/questions/69708336
复制相似问题