-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathchecker.py
49 lines (38 loc) · 1.2 KB
/
checker.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
import asyncio
from sys import argv
import aiohttp
proxy_type = "http"
test_url = "http://www.google.com"
timeout_sec = 4
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
# read the list of proxy IPs in proxyList from the first Argument given
filename = argv[1]
proxylistfile = open(filename)
proxyList = proxylistfile.read().splitlines()
async def is_bad_proxy(ipport):
try:
session = aiohttp.ClientSession()
resp = await session.get(test_url, proxy=ipport, timeout=timeout_sec)
if not resp.headers["Via"]:
raise "Error"
print(bcolors.OKBLUE + "Working:", ipport + bcolors.ENDC)
session.close()
except:
session.close()
print(bcolors.FAIL + "Not Working:", ipport + bcolors.ENDC)
tasks = []
loop = asyncio.get_event_loop()
for item in proxyList:
tasks.append(asyncio.ensure_future(is_bad_proxy("http://" + item)))
print(bcolors.HEADER + "Starting... \n" + bcolors.ENDC)
loop.run_until_complete(asyncio.wait(tasks))
print(bcolors.HEADER + "\n...Finished" + bcolors.ENDC)
loop.close()