Last active
February 18, 2023 15:20
-
-
Save rezkyfm/8543249d2c764e4e0bdd7cd9a9052077 to your computer and use it in GitHub Desktop.
Check if user in github follow you back or not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Check if user in github follow you back or not | |
''' | |
import requests | |
username = input("Enter your username: ") | |
def main(username): | |
# Get followers data | |
followers_api = requests.get( | |
'https://api.github.com/users/'+username+'/followers') | |
followers_json = followers_api.json() | |
followers = [] | |
for f in range(len(followers_json)): | |
followers.append(followers_json[f]['login']) | |
# Get Following data | |
following_api = requests.get( | |
'https://api.github.com/users/'+username+'/following') | |
following_json = following_api.json() | |
following = [] | |
for f in range(len(following_json)): | |
following.append(following_json[f]['login']) | |
# 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