zoukankan      html  css  js  c++  java
  • 域名查询是否注册的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('
    ')
            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('
    ')
                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('
    ')
                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('
    ')
                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
  • 相关阅读:
    关系数据库&&NoSQL数据库
    NoSQL
    大数据时代的数据存储,非关系型数据库MongoDB
    判断是否为BST
    百度2017暑期实习生编程题
    memset()实现及细节
    在必须返回一个对象时,不要去尝试返回一个引用
    返回局部变量指针
    用引用返回值
    数组形参
  • 原文地址:https://www.cnblogs.com/blog-rui/p/11416315.html
Copyright © 2011-2022 走看看