Search code examples
pythonroblox

Roblox Friend Deleter


I'm making a program that uses cookies to log in to my Roblox account and delete all friends, it seems that it does scrape the user IDs correctly and prints them out if deletion succeeded, but it does not actually delete anyone, I am new to Python and I can't think of a fix for this.

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)

Solution

  • Sorry for the late response. I made something like this to unfollow everyone except for terminated users.

    Try my script that should unfriend everyone:

    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
    

    enter image description here

    edit: I had a look at your script and it seems like you forgot to validate the session with an X-CSRF-TOKEN.