Skip to content

Instantly share code, notes, and snippets.

@Xnuvers007
Created November 9, 2025 13:55
Show Gist options
  • Select an option

  • Save Xnuvers007/f5d033e5b1c06f8e7e23a51dd926c060 to your computer and use it in GitHub Desktop.

Select an option

Save Xnuvers007/f5d033e5b1c06f8e7e23a51dd926c060 to your computer and use it in GitHub Desktop.
scraping for codes game roblox
import requests
import random
import datetime
from bs4 import BeautifulSoup
import sys
class Colors:
HEADER = '\033[95m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
END = '\033[0m'
BOLD = '\033[1m'
AQUA = '\033[96m'
SKY = '\033[36m'
USER_AGENTS = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1 Safari/605.1.15',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36',
]
cache = {}
def build_url(game_name: str) -> str:
slug = game_name.strip().lower().replace(" ", "-")
return f"https://beebom.com/{slug}-codes/"
session = requests.Session()
def fetch_page(url: str) -> str:
if url in cache:
return cache[url]
headers = {'User-Agent': random.choice(USER_AGENTS)}
response = session.get(url, headers=headers, timeout=8)
response.raise_for_status()
cache[url] = response.text
return response.text
def parse_codes(html_content: str) -> list:
try:
soup = BeautifulSoup(html_content, 'lxml')
except Exception:
soup = BeautifulSoup(html_content, 'html.parser')
# return [li.get_text(separator=' ', strip=True) for li in soup.select('ul.wp-block-list li') if li.get_text(strip=True)]
ul = soup.find('ul', class_='wp-block-list')
if not ul:
return []
return [li.get_text(separator=' ', strip=True) for li in ul.find_all('li') if li.get_text(strip=True)]
def display_codes(game_name: str, codes: list):
print(f"\n{Colors.BOLD}{Colors.BLUE}Mencari kode untuk: {game_name}{Colors.END}")
print(f"{Colors.YELLOW}Tanggal dan Waktu: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}{Colors.END}\n")
if codes:
for code in codes:
print(f"{Colors.GREEN}• {code}{Colors.END}")
print(f"\n{Colors.BOLD+Colors.AQUA}Total kode ditemukan: {len(codes)}{Colors.END}")
else:
print(f"{Colors.RED}List kode tidak ditemukan di halaman.{Colors.END}")
def main():
while True:
try:
game_name = input(f"{Colors.HEADER}Masukkan nama map/game Roblox: {Colors.END}").strip()
if not game_name:
print(f"{Colors.YELLOW}Nama game tidak boleh kosong!{Colors.END}")
continue
url = build_url(game_name)
html = fetch_page(url)
codes = parse_codes(html)
display_codes(game_name, codes)
print("\n" + "-"*50 + "\n")
ulang = input(f"{Colors.HEADER}Apakah Anda ingin mencoba lagi? (y/n): {Colors.END}").strip().lower()
if ulang != 'y':
print(f"\n{Colors.BOLD}Terima kasih sudah menggunakan pencari kode Roblox Beebom!{Colors.END}")
break
except (KeyboardInterrupt, EOFError):
print(f"\n{Colors.RED}Program dihentikan oleh pengguna.{Colors.END}")
sys.exit()
except requests.exceptions.RequestException as e:
print(f"{Colors.RED}Terjadi kesalahan saat mengakses server: {e}{Colors.END}")
if __name__ == "__main__":
print(f"""{Colors.BOLD}{Colors.SKY}
AUTHOR : Xnuvers007 / Luckysora007
GITHUB : Xnuvers007
YOUTUBE: xnuvers0077
{Colors.END}""")
main()
@Xnuvers007
Copy link
Author

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