-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscraper.py
96 lines (81 loc) · 4.98 KB
/
scraper.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env python3
import time
from datetime import datetime
import threading
import os, sys
from colorama import Fore, Style, init
from pystyle import Colors, Write, Center, Anime, System, Colorate
import random, requests, ctypes
import base64
class Main():
def __init__(self):
self.api = "API.txt"
self.file = "data/scraped_proxies.txt"
self.title = "Proxy Scraper | 6 API's | Open Source"
self.start_title = "PRESS ENTER TO START."
self.author = "𝐖𝐗〢・GoKu xD . 🥀†¹ⱽ¹#0077"
def random_line(file_txt):
line = next(file_txt)
for num, aline in enumerate(file_txt, 2):
if random.randrange(num):
continue
line = aline
return line
def __scrape__(self):
APIS = [
"https://raw.githubusercontent.com/clarketm/proxy-list/master/proxy-list-raw.txt",
"https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/http.txt",
"https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/http.txt",
"https://raw.githubusercontent.com/UptimerBot/proxy-list/main/proxies/http.txt",
"https://raw.githubusercontent.com/clarketm/proxy-list/master/proxy-list-raw.txt",
"https://raw.githubusercontent.com/jetkai/proxy-list/main/online-proxies/txt/proxies-https"
]
randomized_api = random.choice(APIS)
try:
ctypes.windll.kernel32.SetConsoleTitleW(self.title)
API_IN_USE = randomized_api
print(f"[{datetime.now()}] || [{Fore.LIGHTBLACK_EX}DEBUG{Fore.WHITE}] || [{Fore.GREEN}API{Fore.WHITE}] API IN USE : {API_IN_USE}")
session = requests.Session()
ID = session.get("https://wtfismyip.com/text").text.strip("\n")
print(f"[{datetime.now()}] || [{Fore.LIGHTBLACK_EX}DEBUG{Fore.WHITE}] || [{Fore.GREEN}SESSION{Fore.WHITE}] Created Session {ID}")
time.sleep(1)
for i in range(1, 6):
print(f"[{datetime.now()}] || [{Fore.LIGHTBLACK_EX}DEBUG{Fore.WHITE}] || [{Fore.GREEN}TIME{Fore.WHITE}] Time Remaining To Complete Scraping {i}s", end="\r")
time.sleep(1)
response_from_api = requests.get(randomized_api)
data = response_from_api.text
print(f"[{datetime.now()}] || [{Fore.BLUE}INFO{Fore.WHITE}] || [{Fore.GREEN}SCRAPED{Fore.WHITE}] Proxies Scraped from {API_IN_USE}")
with open("data/scraped_proxies.txt", "a") as f:
start_line = """
SCRAPED MADE BY GOKU CODEZ
__________________________________________________________________________________________\n\n
"""
f.write(f"{start_line}\n{data}")
num_lines = sum(1 for line in open('data/scraped_proxies.txt'))
print(f"[{datetime.now()}] || [{Fore.BLUE}INFO{Fore.WHITE}] || [{Fore.GREEN}TOTAL{Fore.WHITE}] Total Proxies Scraped {num_lines}")
with open("raw_data.txt", "a") as f:
f.write(f"{data}")
except Exception as er:
print(f"[{datetime.now()}] || [{Fore.LIGHTBLACK_EX}DEBUG{Fore.WHITE}] || [{Fore.RED}ERROR{Fore.WHITE}] Something Went Wrong Retrying... Exception: {er}")
time.sleep(0.6)
self.__scrape__()
def console(self):
os.system("title "+self.start_title)
banner = r'''
██████ ▄████▄ ██▀███ ▄▄▄ ██▓███ ▓█████ ██▀███
▒██ ▒ ▒██▀ ▀█ ▓██ ▒ ██▒▒████▄ ▓██░ ██▒▓█ ▀ ▓██ ▒ ██▒
░ ▓██▄ ▒▓█ ▄ ▓██ ░▄█ ▒▒██ ▀█▄ ▓██░ ██▓▒▒███ ▓██ ░▄█ ▒
▒ ██▒▒▓▓▄ ▄██▒▒██▀▀█▄ ░██▄▄▄▄██ ▒██▄█▓▒ ▒▒▓█ ▄ ▒██▀▀█▄
▒██████▒▒▒ ▓███▀ ░░██▓ ▒██▒ ▓█ ▓██▒▒██▒ ░ ░░▒████▒░██▓ ▒██▒
▒ ▒▓▒ ▒ ░░ ░▒ ▒ ░░ ▒▓ ░▒▓░ ▒▒ ▓▒█░▒▓▒░ ░ ░░░ ▒░ ░░ ▒▓ ░▒▓░
░ ░▒ ░ ░ ░ ▒ ░▒ ░ ▒░ ▒ ▒▒ ░░▒ ░ ░ ░ ░ ░▒ ░ ▒░
░ ░ ░ ░ ░░ ░ ░ ▒ ░░ ░ ░░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░
░
'''
System.Size(120, 30)
System.Clear()
Anime.Fade(Center.Center(banner), Colors.purple_to_blue, Colorate.Vertical, interval=0.030, enter=True)
self.__scrape__()
if __name__ == "__main__":
Main().console()