Skip to content

Instantly share code, notes, and snippets.

@st1vms
Created September 17, 2024 12:00
Show Gist options
  • Save st1vms/f4bd5e7155041a22050ec94125bf3c7c to your computer and use it in GitHub Desktop.
Save st1vms/f4bd5e7155041a22050ec94125bf3c7c to your computer and use it in GitHub Desktop.
Bot for visitcount.itsvg.in used to auto generate views
"""Visit Count spammer bot"""
import multiprocessing
from time import sleep
import requests
BASE_GITHUB_URL = "https://github.com/"
BASE_VISITCOUNT_URL = "https://visitcount.itsvg.in/api"
BASE_VISITCOUNT_PARAMS = {
"id": None,
"icon": "5",
"color": "1",
}
REQUEST_RATE_SECONDS = 2
BACKOFF_DELAY_SEC = 60
HEADERS = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8",
"Accept-Language": "it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3",
"Sec-GPC": "1",
"Upgrade-Insecure-Requests": "1",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Priority": "u=0, i",
}
def __single_thread_bot(username: str) -> None:
github_link = f"{BASE_GITHUB_URL}{username}"
params = BASE_VISITCOUNT_PARAMS
params["id"] = username
while True:
res = requests.get(
BASE_VISITCOUNT_URL, headers=HEADERS, params=params, timeout=60
)
if res.status_code != 200:
sleep(BACKOFF_DELAY_SEC)
requests.get(github_link, timeout=60)
continue
sleep(REQUEST_RATE_SECONDS)
def __multi_thread_bot(username: str, n_threads: int) -> None:
try:
with multiprocessing.Pool(n_threads) as pool:
pool.map(__single_thread_bot, [username] * n_threads)
except KeyboardInterrupt:
print("\nKeyboardInterrupt detected! Terminating bots...")
pool.terminate()
pool.join()
print("\nAll bots terminated.")
__MENU = """
Select an option
1) Single-threaded spammer
2) Multi-threaded spammer
0) Exit
>>"""
def _menu() -> int:
while True:
try:
c = int(input(__MENU).strip())
if c < 0 or c > 2:
print("\nInvalid choice")
continue
return c
except ValueError:
print("\nInvalid choice...")
continue
def _main() -> None:
username = input("\nInsert your Github username\n>>").strip()
if not username:
print("\nNo username inserted, quitting...")
return
choice = _menu()
if choice == 0:
print("\nQuitting...")
return
print(f"\nYou can check the actual visit count at: {BASE_GITHUB_URL}/{username}")
if choice == 1:
print(f"\nMaking one request each {REQUEST_RATE_SECONDS} seconds...")
__single_thread_bot(username)
return
if choice == 2:
try:
n_threads = int(input("\nInsert number of parallel workers\n>>").strip())
if n_threads < 1:
print("\nInvalid option, quitting...")
return
except ValueError:
print("\nInvalid option, quitting...")
return
print(
f"\nMaking around {n_threads} requests each {REQUEST_RATE_SECONDS} seconds..."
)
__multi_thread_bot(username, n_threads)
if __name__ == "__main__":
_main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment