|
|
|
@ -4,6 +4,8 @@ import time
|
|
|
|
|
from collections import namedtuple
|
|
|
|
|
from colorama import Fore, Style
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def load_proxies_from_csv(path_to_list):
|
|
|
|
|
"""
|
|
|
|
|
A function which loads proxies from a .csv file, to a list.
|
|
|
|
|
|
|
|
|
@ -11,9 +13,6 @@ Inputs: path to .csv file which contains proxies, described by fields: 'ip', 'po
|
|
|
|
|
|
|
|
|
|
Outputs: list containing proxies stored in named tuples.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def load_proxies_from_csv(path_to_list):
|
|
|
|
|
Proxy = namedtuple('Proxy', ['ip', 'port', 'protocol'])
|
|
|
|
|
|
|
|
|
|
with open(path_to_list, 'r') as csv_file:
|
|
|
|
@ -23,6 +22,8 @@ def load_proxies_from_csv(path_to_list):
|
|
|
|
|
return proxies
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_proxy(proxy_ip, proxy_port, protocol):
|
|
|
|
|
"""
|
|
|
|
|
A function which test the proxy by attempting
|
|
|
|
|
to make a request to the designated website.
|
|
|
|
@ -30,9 +31,6 @@ to make a request to the designated website.
|
|
|
|
|
We use 'wikipedia.org' as a test, since we can test the proxy anonymity
|
|
|
|
|
by check if the returning 'X-Client-IP' header matches the proxy ip.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_proxy(proxy_ip, proxy_port, protocol):
|
|
|
|
|
full_proxy = f'{protocol}://{proxy_ip}:{proxy_port}'
|
|
|
|
|
proxies = {'http': full_proxy, 'https': full_proxy}
|
|
|
|
|
try:
|
|
|
|
@ -46,6 +44,11 @@ def check_proxy(proxy_ip, proxy_port, protocol):
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from colorama import Fore, Style
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_proxy_list(proxy_list, max_proxies=None):
|
|
|
|
|
"""
|
|
|
|
|
A function which takes in one mandatory argument -> a proxy list in
|
|
|
|
|
the format returned by the function 'load_proxies_from_csv'.
|
|
|
|
@ -59,11 +62,6 @@ but are sending successive requests each separated by at least 1 sec.
|
|
|
|
|
|
|
|
|
|
Outputs: list containing proxies stored in named tuples.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from colorama import Fore, Style
|
|
|
|
|
|
|
|
|
|
def check_proxy_list(proxy_list, max_proxies=None):
|
|
|
|
|
print((Style.BRIGHT + Fore.GREEN + "[" +
|
|
|
|
|
Fore.YELLOW + "*" +
|
|
|
|
|
Fore.GREEN + "] Started checking proxies."))
|
|
|
|
|