域名查询是否注册的demo
import json import multiprocessing import threading import requests import xmltodict # 万网查询 def check_domin_www(file_path): for line in open(file_path): line = line.strip() try: url = f'''http://panda.www.net.cn/cgi-bin/check.cgi?area_domain={ line }.com''' r = requests.get(url) res_dict = xmltodict.parse(r.content.decode()) domin = res_dict['property']['key'] res = res_dict['property']['original'][:3] print(res_dict) if res == 210: with open('domin_res.txt', 'a') as f: f.write(domin) f.write('\n') except Exception as e: print('出错了') pass # 阿里云查询 def check_domin_aliyun(file_path): for line in open(file_path): line = line.strip() try: url = f'''https://checkapi.aliyun.com/check/checkdomain?domain={ line }.com&token=Yc0dc45c0cbd5d71276b9baf6d419c32f''' r = requests.get(url) res_dict = json.loads(r.content.decode()) if res_dict['success'] == 'true': if res_dict['module'][0]['avail'] == 1: with open('domin_res.txt', 'a') as f: f.write(res_dict['module'][0]['name']) f.write('\n') else: print(res_dict) except Exception as e: print('出错了') pass # now查询 def check_domin_now(file_path): for line in open(file_path): line = line.strip() try: url = f'''https://checkapi.now.cn:8080/?domains={ line }.com''' r = requests.get(url) res_dict = json.loads(r.content.decode()) if res_dict['code'] == 100: if res_dict['results'][0]['status'] == 1: with open('domin_res.txt', 'a') as f: f.write(res_dict['results'][0]['domain']) f.write('\n') else: print(res_dict) except Exception as e: print(e) pass # 中企动力查询 def check_domin_300(file_path): for line in open(file_path): line = line.strip() try: url = f'''https://api-shop.300.cn/domain/findDomainStatus?domainName={ line }&domainSuffix=.com''' r = requests.get(url) res_dict = json.loads(r.content.decode()) if res_dict['status'] == 101: if res_dict['data']['domainStatus'] == 2: with open('domin_res_300.txt', 'a') as f: f.write(f'{ line }.com') f.write('\n') else: print(res_dict) except Exception as e: import traceback print(traceback.print_exc()) def run(file_path): t = threading.Thread(target=check_domin_300, args=(file_path,)) t.start() if __name__ == '__main__': i = 23 while i < 27: p = multiprocessing.Process(target=run, args=('E:/code/Modbus_RTU/passs/pass_{}.txt'.format(i),)) p.start() i += 1