-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhaxorid.py
60 lines (51 loc) · 1.96 KB
/
haxorid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import os
import re
import requests
from tqdm import tqdm
def scrape_website(page_type, total_pages=50):
for page in tqdm(range(0, total_pages), desc=f"Progress {page_type if page_type else 'archive'}"):
url = f'https://haxor.id/archive/{page_type}?page={page}' if page_type else f'https://haxor.id/archive?page={page}'
response = requests.get(url)
html_content = response.text
pattern = re.compile(r'href=["\'](https?://.*?)["\']')
matches = pattern.findall(html_content)
if matches:
with open('haxor.id.txt', 'a') as file:
for href_value in matches:
href_value = re.sub(r'^https?://', '', href_value)
href_value = re.sub(r'/.*', '', href_value)
file.write(f'{href_value}\n')
def menu():
os.system('cls' if os.name == 'nt' else 'clear')
TEXT_COLOR = "\033[93m"
RESET_COLOR = "\033[0m"
print(TEXT_COLOR + '''
__ ______ __ ___
/ /_ ____ _/_ __/___ ____ / /____ _ _< /
__ / / / / / / / // / / __ \/ __ \/ / ___/ | / / / /
/ /_/ / /_/ / /_/ // / / /_/ / /_/ / (__ ) | |/ / /
\____/\__, /\__,_//_/ \____/\____/_/____/ |___/_/
/____/
''' + RESET_COLOR)
print(TEXT_COLOR + '''
Select the page type to grab:
[1] Special (Haxor.id Site)
[2] Archive (Haxor.id Site)
[0] Exit
''' + RESET_COLOR)
choice = input("Enter your choice (1, 2, or 0): ")
if choice == '1':
print("\nYou selected 'Special' page.")
scrape_website('special')
elif choice == '2':
print("\nYou selected 'Archive' page.")
scrape_website('')
elif choice == '0':
print("Exiting...")
sys.exit(0)
elif choice.strip() == "":
menu()
else:
print("Invalid choice. Please select 1, 2, or 0.")
menu()
menu()