Skip to content

Instantly share code, notes, and snippets.

@azlkiniue
Forked from rezkyfm/github-followback-checker.py
Last active February 18, 2023 15:25
Show Gist options
  • Save azlkiniue/0f47c23d3841a6c51ec294a3e941c5c7 to your computer and use it in GitHub Desktop.
Save azlkiniue/0f47c23d3841a6c51ec294a3e941c5c7 to your computer and use it in GitHub Desktop.
Check if user in github follow you back or not
'''
Check if user in github follow you back or not
'''
import requests
username = input("Enter your username: ")
def main(username):
# Get followers data
iter = 1
followers = []
while True:
followers_api = requests.get(
'https://api.github.com/users/'+username+'/followers?per_page=100&page='+str(iter))
followers_json = followers_api.json()
print("iteration", iter)
iter += 1
delta = 0
old = len(followers)
for f in range(len(followers_json)):
followers.append(followers_json[f]['login'])
new = len(followers)
delta = new - old
if delta == 0:
break
# Get Following data
iter = 1
following = []
while True:
following_api = requests.get(
'https://api.github.com/users/'+username+'/following?per_page=100&page='+str(iter))
following_json = following_api.json()
print("iteration", iter)
iter += 1
delta = 0
old = len(following)
for f in range(len(following_json)):
following.append(following_json[f]['login'])
new = len(following)
delta = new - old
if delta == 0:
break
# Get the result
result = list(set(following) - set(followers))
# Return result data
for r in result:
print(r)
if __name__ == "__main__":
main(username)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment