示例#1
0
 def schedule_checker(self, cycle=CHECKER_CYCLE):
     """
     定时测试代理
     """
     checker = ProxyChecker()
     while True:
         print('测试器开始运行')
         checker.run()
         time.sleep(cycle)
示例#2
0
def test():
    with open("proxies.txt", "r+") as extreme:
        os.system("title Proxy Checker by ExtremeDev")
        init()
        dev = extreme.readlines()
        for proxy in dev:
            checker = ProxyChecker()
            value = checker.check_proxy(proxy)
            if 'False' in str(value):
                print(Fore.RED + f"{proxy}" + Fore.WHITE)
                with open("bad.txt", "a+") as write:
                    write.write(f"{proxy}\n")
            else:
                print(Fore.GREEN + f"{proxy}" + Fore.WHITE)
                with open("good.txt", "a+") as write:
                    write.write(f"{proxy}\n")
def check_proxy(proxy, check_against=None):
    proxies = {'https': f'https://{proxy}'}
    valid = True
    checker = ProxyChecker()
    result_checker = checker.check_proxy(proxy)
    if result_checker == False:
        valid = False
    else:
        try:
            response = requests.get(check_against,
                                    headers=HEADERS,
                                    proxies=proxies,
                                    timeout=(5, 10))
            valid &= response.status_code == 200
        except requests.exceptions.RequestException as e:
            valid = False
    return valid
示例#4
0
def check(addres):
    from proxy_checker import ProxyChecker

    global working
    global working_proxies

    if ProxyChecker().check_proxy(addres) != False:
        working_proxies.append(addres)
        working += 1
示例#5
0
def get_proxy():

    """This function performs a search and tests a pool of proxies and then returns a valid & working proxy address.

    Returns:
        str: Proxy in the form of <ipaddress:port>
    """
 
    url = 'https://free-proxy-list.net/'
    response = requests.get(url)
    parser = fromstring(response.text)
    proxies = set()
    for i in parser.xpath('//tbody/tr'):
        if i.xpath('.//td[7][contains(text(),"yes")]'):
            proxy = ":".join([i.xpath('.//td[1]/text()')[0], i.xpath('.//td[2]/text()')[0]])
            proxies.add(proxy)

    print("Checking for Proxies")
    for proxy in proxies:
        checker = ProxyChecker()
        test = checker.check_proxy(proxy)
        print(f'{proxy}:{test}')
        if test:
            return proxy
示例#6
0
文件: main.py 项目: ChinadaCam/Pyet
def main():
    os.system(" Proxy Checker by Death Unity Team")
    file = open("proxies.txt", "r")
    for proxy in file:

        value = ProxyChecker().check_proxy(proxy)
        print(value)
        if 'False' in str(value):
            print(Fore.RED + f"{proxy}" + Fore.WHITE)
            with open("bad.txt", "a") as write:
                write.write(f"{proxy}\n")
        else:
            print(Fore.GREEN + f"{proxy}" + Fore.WHITE)
            with open("good.txt", "a") as write:
                write.write(f"{proxy}\n")

    print(Fore.CYAN + f"Done" + Fore.WHITE)
示例#7
0
class ProxyCheck(XProxy):
    def __init__(self):
        XProxy.__init__(self)
        print('Loading..')
        self.checker = ProxyChecker()
        system('cls')


    def check(self, list_, timeout=5):
        for x in list_:
            c = self.checker.check_proxy(x)
            if c:
                write(Fore.GREEN + '[ALIVE] '+ x + ' | ' + c['anonymity'] + ' | ' + 'Timeout:'+ str(c['timeout']) + ' ' +c['country_code'] + Style.RESET_ALL + ' ' +  c['protocols'][0])
                with open('all_alive.txt', 'a', encoding='UTF-8') as f:
                    f.write(x + '\n')

                if c['protocols'][0] == 'http':
                    with open('http_alive.txt', 'a', encoding='UTF-8') as f:
                        f.write(x + '\n')                    

                elif c['protocols'][0] == 'socks4':
                    with open('socks4_alive.txt', 'a', encoding='UTF-8') as f:
                        f.write(x + '\n')     

                elif c['protocols'][0] == 'socks5':
                    with open('socks5_alive.txt', 'a', encoding='UTF-8') as f:
                        f.write(x + '\n')   
                else:
                    pass

                self.checked_counter += 1
   
            else:
                write(Fore.RED + '[DEAD] ' + x + Style.RESET_ALL)
                with open('dead_proxies.txt', 'a', encoding='UTF-8') as f:
                    f.write(x + '\n')
                self.checked_counter += 1
示例#8
0
from baha.util.proxy_list import PROXY_LIST
from proxy_checker import ProxyChecker

checker = ProxyChecker()
for p in PROXY_LIST:
    ip = p['proxy'].split(':')[1].replace('//', '')
    port = p['port']
    print(ip, port)
    c = checker.check_proxy('{}:{}'.format(ip, port))
    print(c)
 def isValid(self, prox):
     checker = ProxyChecker()
     return checker.check_proxy(prox.get_address())
示例#10
0
    sys.exit(0)

if args.infile:
    proxy_path = Path(args.infile)

    if not proxy_path.is_file():
        raise Exception(
            'Proxyfile not exists. Please run with correct file path.')

    if args.outfile:
        good_proxy_path = proxy_path.parent.joinpath('good_proxy.csv')
else:
    if args.outfile:
        good_proxy_path = Path.cwd().joinpath('good_proxy.csv')

checker = ProxyChecker()


def proxy_handler(proxy_str):
    resp = checker.check_proxy(proxy_str)
    if resp:
        resp['protocols'] = '/'.join(resp['protocols'])
        resp_vals = list(str(i) for i in resp.values())
        return f'{proxy_str},{",".join(resp_vals)}\n'


if __name__ == '__main__':
    data = 'ip:port,protocols,anonymity,timeout,country,country_code\n'
    print('  '.join(i if n % 2 == 0 else f'\033[95m{i}\033[0m'
                    for n, i in enumerate(data.strip().split(','))))
示例#11
0
 def __init__(self):
     XProxy.__init__(self)
     print('Loading..')
     self.checker = ProxyChecker()
     system('cls')
示例#12
0
def check_proxy(proxy):
    checker = ProxyChecker()
    check_proxy.r = checker.check_proxy(proxy)
示例#13
0
文件: main.py 项目: ctj01/checker
def check_proxy_(proxy):
    checker = ProxyChecker()
    x = checker.check_proxy(proxy)
    if x != False:
        return proxy