-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
57 lines (40 loc) · 1.61 KB
/
example.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
from proxy_checker import ProxyChecker
import signal
import sources
def main():
"""
The main function to harvest, check, and manage proxies.
This function orchestrates the proxy harvesting, checking, and management process.
It fetches proxies from different sources, checks their validity, stores valid proxies,
and prints the total number of proxies obtained from all sources.
Raises:
Exception: If an error occurs during the proxy harvesting or checking process.
"""
source = sources.SslProxiesSource()
print(f"Proxies: {len(source.get_proxies())} in {source.__class__.__name__}")
source = sources.ProxyScrapeSource()
print(f"Proxies: {len(source.get_proxies())} in {source.__class__.__name__}")
# source = sources.DidSoftSource(email="[email protected]", password="password")
# print(f"Proxies: {len(source.get_proxies())} in {source.__class__.__name__}")
proxy_checker = ProxyChecker([
sources.SslProxiesSource(),
sources.ProxyScrapeSource(),
])
proxy_checker.do_the_thing()
proxies = proxy_checker.get_proxy_list()
print(f"Proxies: {len(proxies)} in many `sources`")
def handler(signum, frame):
"""
Signal handler function for SIGINT (Ctrl+C) signal.
Args:
signum (int): The signal number.
frame (frame): The current stack frame.
"""
print(f"Received SIGINT signal. Houston, we are going back home ...")
exit(1)
signal.signal(signal.SIGINT, handler)
if __name__ == "__main__":
try:
main()
except Exception as e:
print(f"Houston, some nasty alien said something. {e}")