python 自动批量查找未注册域名

实现批量查找未注册域名, 看看有没有想要的域名吧.

自定义域名后缀 如:.com .cn 等
自定义域名长度
自定义域名组合方式 1.纯字母 2.纯数字 3.混合
查找到可以注册的域名保存到txt文本,方便筛选
使用python3.x版本即可运行

#!usr/bin/python
#coding=utf-8
import random
import string
import urllib.request
import xml.etree.ElementTree as ET
import threading

isnum = 3 #1.纯字母 2.纯数字 3.混合
maxlen = 5 #域名长度, 例设置5 搜索长度不大于5的域名
suffixList = ['.com','.cn','.vip','.co']  #域名后缀,根据需要填写
alist = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't','u', 'v', 'w', 's', 'y', 'z']
nlist = ['0','1','2','3','4','5','6','7','8','9']



mylock = threading.RLock()

def randomCreationDomain():
     dlen = random.randint(1, maxlen)
     randomain = ""
     #
     if isnum == 1:
         randomain = ''.join(random.sample(alist, dlen)).replace(" ", "")
     elif isnum == 2:
         randomain = ''.join(random.sample(nlist, dlen)).replace(" ", "")
     elif isnum == 3:
         randomain = ''.join(random.sample(string.ascii_letters + string.digits, dlen))
     for suffix  in suffixList:
         domain = randomain + suffix
         netwoke(domain,suffix)



def netwoke(domain,suffix):
    response = urllib.request.urlopen('http://panda.www.net.cn/cgi-bin/check.cgi?area_domain='+domain)
    print(domain)
    result = response.read().decode("utf-8")
    #print(result)
    doc = ET.fromstring(result)
    code = doc[0].text
    if code == '200':
        original = doc[2].text
        if '210' in original:
             mylock.acquire()
             with open("domain_%s.txt"%suffix, 'a+') as f:
                   f.writelines(str(domain + '\n'))
             print('===succeed===',domain)
             mylock.release()


class myThread(threading.Thread):
    def __init__(self, name):
        threading.Thread.__init__(self)
        self.t_name = name

    def run(self):
        while True:
            randomCreationDomain()


if __name__== '__main__':
    thread1 = myThread("1")
    thread1.start()
    thread2 = myThread("2")
    thread2.start()
    thread3 = myThread("3")
    thread3.start()

下载源码 http://pan.baidu.com/s/1kUEzFJT

运行之后,可注册的域名保存如图

python 自动批量查找未注册域名_第1张图片
屏幕快照 2017-11-02 下午3.46.05.png
python 自动批量查找未注册域名_第2张图片
屏幕快照 2017-11-02 下午3.47.48.png

推荐一个linux命令行网站:https://rootopen.com

你可能感兴趣的:(python 自动批量查找未注册域名)