python3批量查询域名是否注册

#!/usr/local/bin/python3
#coding=utf-8

import re,sys,os,random,time, base64
import urllib.parse, urllib.request
import socket

timeout = 10
socket.setdefaulttimeout(timeout)

proxy_list = [
{'ip':"222.217.99.129", 'port':"9000", 'type':"http"},
{'ip':"59.53.92.7", 'port':"8090", 'type':"http"},
{'ip':"58.83.224.217", 'port':"8080", 'type':"http"},
{'ip':"218.247.244.155", 'port':"8080", 'type':"http"},
{'ip':"59.173.247.162", 'port':"8888", 'type':"http"},
{'ip':"125.39.93.68", 'port':"8888", 'type':"http"},
{'ip':"221.2.80.126", 'port':"8888", 'type':"http"},
{'ip':"221.235.205.66", 'port':"8090", 'type':"http"},
{'ip':"220.181.159.60", 'port':"8080", 'type':"http"},
{'ip':"218.247.244.23", 'port':"8888", 'type':"http"},
{'ip':"218.241.153.43", 'port':"8080", 'type':"http"},
{'ip':"125.39.93.69", 'port':"8888", 'type':"http"},
{'ip':"211.144.76.7", 'port':"8181", 'type':"http"},
{'ip':"58.53.192.218", 'port':"8123", 'type':"http"},
{'ip':"222.92.141.155", 'port':"8090", 'type':"http"},
{'ip':"59.108.53.1", 'port':"8080", 'type':"http"},
{'ip':"203.93.28.166", 'port':"8080", 'type':"http"},
{'ip':"60.190.189.214", 'port':"8123", 'type':"http"},
{'ip':"59.36.183.178", 'port':"8081", 'type':"http"},
{'ip':"121.11.149.250", 'port':"8081", 'type':"http"},
{'ip':"212.50.244.8", 'port':"8081", 'type':"http"},
{'ip':"216.113.208.185", 'port':"8081", 'type':"http"},
{'ip':"220.181.159.23", 'port':"8080", 'type':"http"},
{'ip':"59.44.204.198", 'port':"8088", 'type':"http"},
{'ip':"221.2.174.164", 'port':"8082", 'type':"http"},
{'ip':"178.135.59.142", 'port':"8090", 'type':"http"},
{'ip':"202.57.4.124", 'port':"8089", 'type':"http"},
{'ip':"211.100.52.196", 'port':"8090", 'type':"http"},
{'ip':"211.144.76.58", 'port':"9000", 'type':"http"}
]

def request_domain(domain):
    have_error = True
    while have_error:
        try:
            url = 'http://pandavip.www.net.cn/check/check_ac1.cgi'
            user_agent = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)'
            values = {'domain' : domain,}
            headers = { 'User-Agent' : user_agent }
            data = urllib.parse.urlencode(values).encode()
            req = urllib.request.Request(url, data, headers)

            index = random.randint(0, len(proxy_list) - 1)
            proxy = proxy_list[index]

            if True:
                proxy_support = urllib.request.ProxyHandler({proxy['type']: proxy['ip'] +':' + proxy['port']})
                opener = urllib.request.build_opener(proxy_support)
                urllib.request.install_opener(opener)

            response = urllib.request.urlopen(req)
            the_page = response.read().decode("utf8")

        except Exception as e:
            have_error = True
            proxy_list.pop(index)
##            print(">>>>>>>>>>> EXCEPTION:  " + proxy['ip']+ " " + str(e))
        else:
            have_error = False
    else:
        return the_page

def construct_domain():
    domainList = []
    domainList.append({'pre': "doucube", 'ext': "com"})
    domainList.append({'pre': "doucube", 'ext': "net"})
    domainList.append({'pre': "doucube", 'ext': "org"})
    domainList.append({'pre': "doucube", 'ext': "cn"})

    for i in range(97, 123):
        domain_pre = chr(i)
        domainList.append({'pre': domain_pre, 'ext': "cn"})

    return domainList

def main():

    domains = construct_domain()

    for i in range(0, len(domains)):
        domain_full = domains[i]['pre'] + "." + domains[i]['ext']
        result = request_domain(domain_full)
        cur_time        = str(time.strftime("%H:%M:%S", time.localtime()))
        if result.find("is not available") != -1:
            print(cur_time + "\t" + domain_full + "\tOccupied!")
        elif result.find("is available") != -1:
            print(cur_time + "\t" + domain_full + "\tFREE! ------->$")
        else:
            print(cur_time + "\t" + domain_full + "\t" + result)

if __name__ == '__main__':
    main()
    print(base64.b64decode(b'Q29weXJpZ2h0IChjKSAyMDEyIERvdWN1YmUgSW5jLiBBbGwgcmlnaHRzIHJlc2VydmVkLg==').decode())

 

运行结果:

*** Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win32. ***
>>>
*** Remote Interpreter Reinitialized  ***
>>>
12:21:12    doucube.com    Occupied!
12:21:15    doucube.net    FREE! ------->$
12:21:29    doucube.org    FREE! ------->$
12:21:30    doucube.cn    FREE! ------->$
12:21:30    a.cn    Occupied!
12:21:33    b.cn    Occupied!
12:21:35    c.cn    Occupied!
12:21:35    d.cn    Occupied!
12:21:37    e.cn    Occupied!
12:21:38    f.cn    Occupied!
12:21:38    g.cn    Occupied!
12:21:42    h.cn    Occupied!
12:21:42    i.cn    Occupied!
12:21:43    j.cn    Occupied!
12:21:45    k.cn    Occupied!
12:21:49    l.cn    Occupied!
12:21:50    m.cn    Occupied!
12:21:50    n.cn    Occupied!
12:21:50    o.cn    Occupied!
12:21:53    p.cn    Occupied!
12:21:53    q.cn    Occupied!
12:21:56    r.cn    Occupied!
12:21:56    s.cn    Occupied!
12:22:06    t.cn    Occupied!
12:22:07    u.cn    Occupied!
12:22:08    v.cn    Occupied!
12:22:08    w.cn    Occupied!
12:22:08    x.cn    Occupied!
12:22:10    y.cn    Occupied!
12:22:11    z.cn    Occupied!

Copyright (c) 2012 Doucube Inc. All rights reserved.

>>> 

 

时间: 2024-09-03 18:04:31

python3批量查询域名是否注册的相关文章

有好米怎么批量查询域名?

  有好米域名批量查询,是专门针对多线程 域名批量查询 研发的软件.首次使用时,请 点击窗口右上角 设置按钮, 进行 域名的后缀进行设置. 然后在规则查询里进行 输入规则 也可以 使用 字典功能. 字典功能 支持 汉字自动转换全拼 和 汉字自动转换全拼首写. 更多强大功能请亲自体验.

有好米域名批量查询好用吗

  支持多线程,查询速度超快. 采用多线程独立查询域名是否注册,并有辅助线程查询 其它域名信息,为提高查询速度建立坚强后盾.在频繁查询时, 域名服务器,可能无法及时返回信息,可以尝试使用 查询等待, 有效避免服务器忙的域名状态. 重新查询,域名信息一个不漏 支持批量查询时,域名服务器忙导致的无法获取域名信息. 增加了,重新查询,一键点击,一直重新查询,直到没有服务器忙 导致的域名信息失效的现象. 支持txt记事本,字典文件. 独家创新,域名也可以使用字典文件. 汉字自动转换为拼音,汉字自动转换为

如何查询域名是否曾被注册过

有很多站长以为域名注册其实非常简单,往往只是查看下注册的状态,就马上注册,其实这种想法很不全面,选择域名前,对域名做细致的考察时非常必要的.考察域名主要就是考察域名是否有过使用历史,因为有过使用历史的域名很有可能是被K过的域名,假如自己买个域名辛苦做网站却发现曾进入过小黑屋,那会是什么样的感觉.要想知道域名是否被注册过,可以通过以下几个方面来判断. 1.首先要到域名查询中心查询域名whois信息. 2.查询域名的外链信息 使用DOMAIN指令或者双引号查看域名相关外链. 3.查看网站被各大搜索引

ASP查询域名是否被注册

<html> <title>ASP查询域名是否被注册</title> <style>  body td {  font-size:12px;  } </style> <body> <table width="400" height="126" border="0" align="center" cellpadding="0" ce

骗子利用域名向注册人和企业行骗的三大伎俩

3日,本报刊登了报道<"域名续费"钓得70家公司>,引起了强烈反响.除了一些受骗者向记者反映类似遭遇外,业内人士.中国万网厦门分公司总经理何春专门向本报记者介绍了骗子利用域名向注册人和企业行骗的三大伎俩. 1.安排假买家诱骗客户 由于域名是一个稀缺网络资源,同一类型域名都是惟一的,一旦被注册便没有第二个相同的,所以现在国内有相当多的专业人士专门做域名投资,人称"玉米虫". 诈骗公司会选择不懂行的客户下手,一般会将域名投资的前景和回报描述得非常好,向客户推

Whois查询域名信息需要注意安全

中介交易 SEO诊断 淘宝客 云主机 技术大厅 写这篇文章是因为很久以前看到两篇关于whois的文章,一篇文章说,在某个网站上查询一个域名,过几天去注册,发现这个域名被注册商自己注册了;另外一篇文章说,在国外的某网站上查询域名信息,不管你要不要,它都会给你注册,你只能再它那里注册了. 另外,有几次,我用google搜索某个域名,搜索到一些whois网站有这个域名相关的网页,原来一些whois查询网站会记录用户查询那些域名,并把这些信息当做这个网站的一个网页;更甚者,一些whois查询网站上会显示

百度收购传课网 “百度传课”域名已注册

中介交易 http://www.aliyun.com/zixun/aggregation/6858.html">SEO诊断 淘宝客 云主机 技术大厅 易名中国(eName.cn)8月4日讯,曾与腾讯闹绯闻的传课网(chuanke.com),最终归属于百度,成为对方旗下的全资子公司,日后"传课网"或将更名为"百度传课",四拼域名已注册. 传课网 去年年底有消息称,"传课网"获得百度350万美元战略投资,一方面可使百度提前布局在线教育

单字母CN域名早在CN二级域名开放注册之前被抢光

据一位域名界人士透露,g.cn.b.cn等单字母CN域名早在CN二级域名开放注册之前就被一抢而光,而CNNIC从未对此做出解释. 该人士称,近日他通过CCNIC提供的whois域名注册查询系统发现,包括g.cn.b.cn在内的多数CN域名早在2003年3月10日就已被相关人士一抢而光,而这一时间要远早于CN二级域名正式开放日期--2003年3月17日. 记者登陆CCNIC官方网站发现,他们并未公布单字母CN域名被注册这一消息,仅称"2003年3月17日,CN二级域名正式开放,今后用户可以在顶级域

CM域名开放注册受阻 米农仍对其锲而不舍

CM域名开放注册受阻 米农仍对其锲而不舍 CM域名无疑是最近域名界的闪光点,自从在一个月前宣布要开放注册以来,它就备受追捧,一股股CM热潮在域名界涌动起来,即使在8月期间一度出现故障而停止开放注册,也打消不了米农们对它穷追不舍的热情. CM域名属于typo域名,拼写和.com与.cn域名相近,人们输入错的域名使用频率非常高,能够给网站带来客观的流量,因此具有很高的商业价值,从而才会受到那么多人的追捧.据时代互联(www.now.cn)相关人士透露,CM域名宣布要开放注册后,在8月1日前就有用户开