Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ Run the script as described in the installation section.
The script will generate random usernames and check their availability on GitHub.
Available usernames will be saved to a text file named available_usernames.txt.


### Check a specific username

You can check a single, specific username instead of running the random scanner:

```bash
python checker.py --username 96ibman
```

- If the username is taken, the script prints the GitHub profile link.
- If the username is available, it prints "USERNAME AVAILABLE" and writes it to `available2usernames.txt`.

### Contributing

We welcome contributions to improve this project. To contribute, please follow these steps:
Expand Down
102 changes: 82 additions & 20 deletions checker.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import requests
import argparse
import random
import string
import time
from colorama import Fore
import requests
from colorama import Fore, init as colorama_init

colorama_init(autoreset=True)

aqua = """
AQUA = r"""

██╗ ██╗ ██████╗ ██╗ ██╗██╗ ██╗
██║ ██║██╔═══██╗ ██║ ██║██║ ██║
Expand All @@ -12,26 +16,84 @@
██║╚██████╔╝ ╚██████╔╝ ██║
╚═╝ ╚══▀▀═╝ ╚═════╝ ╚═╝

--------------------------------------------------
"""
-------------------------------------------------- ...
"""

print(Fore.BLUE + f"{aqua}" + Fore.RESET)
SESSION = requests.Session()
SESSION.headers.update({
"User-Agent": "github-username-availability-checker/0.1 (+https://github.com/4q-u4/GitHub-Username-Availability-Checker)"
})
TIMEOUT = 5.0
PROFILE_URL = "https://www.github.com/{username}/"
OUTPUT_FILE = "available2usernames.txt"

def check_username(username: str) -> str:
"""Return 'taken', 'available', or 'unknown'."""
try:
resp = SESSION.get(PROFILE_URL.format(username=username), timeout=TIMEOUT)
except requests.RequestException:
return "unknown"
if resp.status_code == 200:
return "taken"
if resp.status_code == 404:
return "available"
return "unknown"

while True:
user = ""
for character in random.choices("abcdefghijklmnopqrstuvwxyz123456789", k=3):
user = user + character
def print_banner():
print(Fore.BLUE + AQUA + Fore.RESET)

response = requests.get(f"https://www.github.com/{user}/")

if response.status_code == 200:
print(Fore.RED + f"USERNAME TAKEN: {user}" + Fore.RESET)
elif response.status_code == 404:
print(Fore.GREEN + f"USERNAME AVAILABLE: {user}" + Fore.RESET)
# Append available usernames to a text file
with open("available2usernames.txt", "a") as file:
file.write(user + "\n")
def handle_result(username: str, status: str):
if status == "taken":
print(Fore.RED + f"USERNAME TAKEN: {username}")
print(Fore.RED + f"https://github.com/{username}")
elif status == "available":
print(Fore.GREEN + f"USERNAME AVAILABLE: {username}")
try:
with open(OUTPUT_FILE, "a", encoding="utf-8") as f:
f.write(username + "\n")
except OSError:
print(Fore.YELLOW + "Could not write to output file.")
else:
print("BLOCKED FROM GITHUB")
print(Fore.YELLOW + "Request blocked or unknown status. Backing off for 120 seconds...")
time.sleep(120)

def generate_random_username(length: int = 3) -> str:
alphabet = list(string.ascii_lowercase) + list("123456789")
return "".join(random.choice(alphabet) for _ in range(length))

def run_random_loop(sleep_between: float = 0.2):
while True:
user = generate_random_username(3)
status = check_username(user)
handle_result(user, status)
time.sleep(sleep_between)

def main():
parser = argparse.ArgumentParser(
description="Check GitHub username availability or scan randomly."
)
parser.add_argument(
"--username",
help="Check a specific username once. If omitted, runs the random scanner.",
type=str,
)
parser.add_argument(
"--sleep",
help="Delay in seconds between random checks. Default 0.2",
type=float,
default=0.2,
)
args = parser.parse_args()

print_banner()

if args.username:
name = args.username.strip()
status = check_username(name)
handle_result(name, status)
return

run_random_loop(sleep_between=args.sleep)

if __name__ == "__main__":
main()