Roblox好友删除器

Roblox friend deleter

我正在制作一个使用 cookie 登录 roblox 帐户并删除所有朋友的程序,它似乎确实正确地抓取了用户 ID 并在删除成功时将其打印出来,但它实际上并没有删除任何人,我是新手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)

抱歉回复晚了。我做了这样的事情来取消关注除了终止用户之外的所有人。

试试我的脚本,让每个人都不再友好:

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-CSRF-TOKEN 验证会话。