I was wondering how would I unfollow someone using PyGithub
It's a program that unfollows every person that follows me (to follow organizations only)
I tried the following code but it gave me 404 page not found
with a link to the documentation of the REST API:
from github import Github, Auth
print("Authintincating...")
auth = Auth.Token("My Private Token")
g = Github(auth=auth)
print("Making a list of followers...")
user = g.get_user()
followers = []
for follower in user.get_followers():
followers.append(follower)
print(f"INFO: Got a list of {len(followers)} followers.\n\nChecking if you follow any of your followers...")
num = 0
for follow in user.get_following():
if follow in followers:
user.remove_from_following(follow)
print(f"Unfollowed: {follow.login}")
num += 1
print(f"Found {num} user(s) that you follow and they also follow you.")
Error github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/users/followers#unfollow-a-user", "status": "404"}
This error is occurring internally on PyGithub's package, you should refer to https://github.com/PyGithub/PyGithub/issues/2574 or create a new issue if that one doesn't solve your problem.