python3批量查询域名是否注册

简介: #!/usr/local/bin/python3 #coding=utf-8 import re,sys,os,random,time, base64 import urllib.parse, urllib.
#!/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.

>>> 

 

目录
相关文章
JSON 监控 API
409 0
|
数据库 Python
【YashanDB知识库】python驱动查询gbk字符集崖山数据库CLOB字段,数据被驱动截断
【YashanDB知识库】python驱动查询gbk字符集崖山数据库CLOB字段,数据被驱动截断
|
存储 小程序 Python
农历节日倒计时:基于Python的公历与农历日期转换及节日查询小程序
### 农历节日倒计时:基于Python的公历与农历日期转换及节日查询小程序 该程序通过`lunardate`库实现公历与农历的日期转换,支持闰月和跨年处理,用户输入农历节日名称后,可准确计算距离该节日还有多少天。功能包括农历节日查询、倒计时计算等。欢迎使用! (239字符)
1455 86
|
缓存 算法 API
查询域名WHOIS信息免费API接口教程
该API用于查询顶级域名的WHOIS信息,不支持国别域名和中文域名。通过POST或GET请求,需提供用户ID、KEY及待查询域名。返回信息包括域名状态、注册商、时间等详细数据。示例与文档见官网。
1753 5
|
测试技术 API 数据安全/隐私保护
Python连接到Jira实例、登录、查询、修改和创建bug
通过使用Python和Jira的REST API,可以方便地连接到Jira实例并进行各种操作,包括查询、修改和创建Bug。`jira`库提供了简洁的接口,使得这些操作变得简单易行。无论是自动化测试还是开发工作流的集成,这些方法都可以极大地提高效率和准确性。希望通过本文的介绍,您能够更好地理解和应用这些技术。
1775 0
|
域名解析 网络协议
非阿里云注册域名如何在云解析DNS设置解析?
非阿里云注册域名如何在云解析DNS设置解析?
|
SQL 前端开发 Python
基于python-django的neo4j人民的名义关系图谱查询系统
基于python-django的neo4j人民的名义关系图谱查询系统
511 0
|
数据采集 人工智能 自然语言处理
AI Agent 金融助理0-1 Tutorial 利用Python实时查询股票API的FinanceAgent框架构建股票(美股/A股/港股) AI Finance Agent
金融领域Finance AI Agents方面的工作,发现很多行业需求和用户输入的 query都是和查询股价/行情/指数/财报汇总/金融理财建议相关。如果需要准确的 金融实时数据就不能只依赖LLM 来生成了。常规的方案包括 RAG (包括调用API )再把对应数据和prompt 一起拼接送给大模型来做文本生成。稳定的一些商业机构的金融数据API基本都是收费的,如果是以科研和demo性质有一些开放爬虫API可以使用。这里主要介绍一下 FinanceAgent,github地址 https://github.com/AI-Hub-Admin/FinanceAgent
|
iOS开发 MacOS Python
Python编程小案例—利用flask查询本机IP归属并输出网页图片
Python编程小案例—利用flask查询本机IP归属并输出网页图片
338 1

推荐镜像

更多