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

2020-01-08 19:12:18 +08:00
 wework

首先你要准备好 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

2521 次点击
所在节点    分享创造
5 条回复
lhx2008
2020-01-08 19:44:18 +08:00
1 万次还不够剔牙的,而且单字符域名一般都是注册不了的,只能联系注册局注册
wework
2020-01-08 20:06:03 +08:00
@lhx2008 https://yy.team/available-single-character-cctld-domains 里面的都是可以直接注册
wework
2020-01-08 20:08:11 +08:00
比如里面的 m.mp g.ps p.ps 都是可以直接注册
sobigfish
2020-01-14 14:32:26 +08:00
@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
2020-01-14 14:46:11 +08:00
@sobigfish g.ps 是可以注册的 netim.com 提交即可

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/636257

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX