批量检测可用域名

在《内网IP自动获取》的评论中,有个网友希望能帮忙写一个批处理来批量检测域名的可用性。但前两天都在赶文档,刚刚接到老师电话说推迟到1008日交,心头大石终于落地^_^。所以就马上开工帮那位朋友实现这个批处理!

原理很简单,就是找一个域名注册网站(比如我这里找的中国域名为 http://www.chinadomain.com.cn/),这类网站一般都提供了域名查询功能,我们只要用 curl 等命令行 Web 客户端来提交表单就能获得域名的信息,然后通过 grep 来提取可用域名。

:这两个工具在 Linux 系统中是自带的,但 Windows 中没有。我已经将它们和批处理文件一起上传到我的 Google Sites (https://sites.google.com/site/redraiment/sunshine/domain)里,方便大家下载。下面是批处理的代码:

:: 查询可用域名 :: 使用方法:domain.bat hostname ... :: By redraiment @echo off :loop if "%1"=="" goto end curl "http://www.chinadomain.com.cn/whoischeck.asp?domain_type=en_domain&ifcn=en&name=%1&imageField44.x=0&imageField44.y=0&suffix=.com&suffix=.com.cn&suffix=.cn&suffix=.net&suffix=.net.cn&suffix=.org&suffix=.org.cn&suffix=.biz&suffix=.info&suffix=.mobi&suffix=.tel&suffix=.me&suffix=.cc&suffix=.hk&suffix=.tv&suffix=.asia&suffix=.name&suffix=.gov.cn" 2>nul | grep -Eo "%1(.[a-z]+)+</td><td[^>]*>可以注册" | grep -Eo "^[^<]*" shift goto loop :end

运行效果如下图所示(查询 CSDN redraiment 的可用域名):

批量检测可用域名


版权声明

请尊重原创作品。转载请保持文章完整性,并以超链接形式注明原始作者“redraiment”和主站点地址,方便其他朋友提问和指正。

联系方式

我的邮箱,欢迎来信(redraiment@gmail.com
我的Blogger(子清行):http://redraiment.blogspot.com/
我的Google Sites(子清行):https://sites.google.com/site/redraiment
我的CSDN博客(梦婷轩):http://blog.csdn.net/redraiment
我的百度空间(梦婷轩):http://hi.baidu.com/redraiment

上一篇:软件测试丨自动化测试之读取配置文件


下一篇:测试开发基础 mvn test | 利用 Maven Surefire Plugin 做测试用例基础执行管理