Skip to content

Instantly share code, notes, and snippets.

@sht
Last active February 3, 2024 08:28
Show Gist options
  • Save sht/6295cb74489545d1c429eab7bfa5f9d4 to your computer and use it in GitHub Desktop.
Save sht/6295cb74489545d1c429eab7bfa5f9d4 to your computer and use it in GitHub Desktop.
to check weather a given username in the file exist on github or not
import string, random, requests, json
def generateUser(size=3, chars=string.ascii_lowercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
for x in range(200):
user = generateUser()
try:
jsonData = json.loads(
requests.get(f"https://api.github.com/users/{user}").text
)
print (jsonData['login'] + ' exist, created at: ' + jsonData['created_at'][:-10])
except Exception as e:
print (f'User: {user}, does not exist\n')
exit()
@sht
Copy link
Author

sht commented Mar 12, 2021

Sample output:

qzn exist, created at: 2015-03-13
qzo exist, created at: 2014-06-22
qzf exist, created at: 2015-01-07
User: raw, does not exist
rfj exist, created at: 2015-04-18
rgq exist, created at: 2016-01-18
rgy exist, created at: 2018-01-30

@sht
Copy link
Author

sht commented Mar 12, 2021

check if a given github username is available or not

@sht
Copy link
Author

sht commented Mar 12, 2021

Sample output:

DU9 exist, created at: 2019-05-16
1XM exist, created at: 2017-06-01
User: u4t, does not exist
uto exist, created at: 2011-01-05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment