修复python代码多线程获取all_domain:import timeimport whoisimport randomimport stringimport itertoolsfrom concurrentfutures import ThreadPoolExecutordef check_domain_availabilitydomain_name if domain_name no
import time import whois import random import string import itertools from concurrent.futures import ThreadPoolExecutor
def check_domain_availability(domain_name): if domain_name not in checked_list: try: whois.whois(domain_name) except: # return "Domain is available for registration" print(f'Checking domain status:{domain_name}') domain_available_list.append(domain_name) with open("output.txt", "a+") as file: file.write(domain_name + '\n') return True else: # return "Domain is not available for registration" print(f'Checking domain status:{domain_name}') checked_list.append(domain_name) return False else: print(domain_name + ' in the list.')
def generate_domain(): letters_string = 'abcdefghijklmnopqrstuvwxyz' letters_number = '0123456789' domain_name_num = ''.join(random.choice(letters_number) for i in range(random.randint(1, 1))) domain_name_str = ''.join(random.choice(letters_string) for i in range(random.randint(1, 1))) domain_name = list(domain_name_num + domain_name_num + domain_name_str + domain_name_str) random.shuffle(domain_name) shuffled_domain = ''.join(domain_name) return shuffled_domain + '.com'
domain_available_list = [] checked_list = []
with ThreadPoolExecutor(max_workers=100) as executor: is_true = False if is_true: all_chars = string.ascii_letters + string.digits + string.punctuation only_letter = 'abcdefghijklmnopqrstuvwxyz' only_number = '1234567890' for length in range(4, 5): for password in itertools.product(only_letter, repeat=length): passwords = ''.join(password) + '\n' with open("all_domains.txt", "a+") as file: file.write(passwords) with open('all_domains.txt', 'r') as f: lines = f.readlines() i = 0 while 1: i += 1 time.sleep(0.1) threads = [] for j in range(100): t = executor.submit(check_domain_availability, lines[random.randint(0, len(lines) - 1)].strip() + '.com') threads.append(t) for thread in threads: pass if i >= 100: print(f'No of Domain:{len(domain_available_list)}\n{domain_available_list}') i =
原文地址: https://www.cveoy.top/t/topic/gJn5 著作权归作者所有。请勿转载和采集!