Python 实现批量查询域名可用性 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
wework
V2EX    分享创造

Python 实现批量查询域名可用性

  •  
  •   wework 2020 年 1 月 8 日 3126 次点击
    这是一个创建于 2279 天前的主题,其中的信息可能已经有所发展或是发生改变。

    首先你要准备好 python3 的执行环境,并且安装 requests 库

    如果没有 python3 执行环境,打开 https://www.anaconda.com/distribution/ ,下载对应操作系统的 anaconda 进行安装

    然后访问 https://rapidapi.com ,注册好帐号,打开 https://rapidapi.com/domainr/api/domainr,通过绑定信用卡订阅 domainr 免费域名查询套餐,该套餐提供每月 10000 次的免费域名查询请求

    python 查询代码如下

    import requests, json import time F1 = open(r'C:\Users\Administrator\av.txt', 'w')#保存查询结果 domains_file = r'C:\Users\Administrator\domains.txt'#加载待查询域名 url = "https://domainr.p.rapidapi.com/v2/status" headers = { 'x-rapidapi-host': "domainr.p.rapidapi.com", 'x-rapidapi-key': "rapidapi 密钥" } def get_domains(): with open(domains_file,'r',encoding='utf-8') as f: domains = f.readlines() domain_list = [i.strip() for i in domains] return domain_list domains = get_domains() for i in range(len(domains)): try: querystring = {"domain":domains[i],"mashape-key":"rapidapi 密钥"} respOnse= requests.request("GET", url, headers=headers, params=querystring) F1.write(domains[i]+":"+response.json()['status'][0]['status']+"\n") except: pass time.sleep(2)#保证查询稳定性和可靠性 F1.close() 

    本人非计算机专业,没有经过系统科学的编程课程培训,所以比较菜,代码都是网上东拼西凑而成,经过测试基本可以满足需求

    基于以上代码,我还做了一个 web 小应用,定期更新当前可以注册的二位后缀单字符域名,有兴趣的朋友可以看看

    世界最短域名监控 https://yy.team/available-single-character-cctld-domains

    5 条回复    2020-01-14 14:46:11 +08:00
    lhx2008
        1
    lhx2008  
       2020 年 1 月 8 日 via Android
    1 万次还不够剔牙的,而且单字符域名一般都是注册不了的,只能联系注册局注册
    wework
        2
    wework  
    OP
       2020 年 1 月 8 日
    @lhx2008 https://yy.team/available-single-character-cctld-domains 里面的都是可以直接注册
    wework
        3
    wework  
    OP
       2020 年 1 月 8 日
    比如里面的 m.mp g.ps p.ps 都是可以直接注册
    run2
        4
    run2  
       2020 年 1 月 14 日
    @wework #3 whois g.ps
    Domain Name: g.ps
    Domain Status: Prohibited String - Object Cannot Be Registered
    Notes: This name is not allowed by the policy of this registry, and can not be registered
    URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
    wework
        5
    wework  
    OP
       2020 年 1 月 14 日
    @sobigfish g.ps 是可以注册的 netim.com 提交即可
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2301 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 37ms UTC 00:48 PVG 08:48 LAX 17:48 JFK 20:48
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86