java实现批量注册_Java写的批量域名注册查询程序

今天得到消息,cn域名又可以注册了,因为前一阵子宫刑部大扫荡了一把,把个人注册的cn域名全部收回,所以现在很多好的cn域名都还存在.

我也是个域名控,但是总不能挨个挨个的去搜域名吧.这里提供一个Java程序.早上写的.

但是可能需要大家自己去物色判断域名是否被注册的URL。本站不提供.

注意 在运行本程序之前 请先 在d盘下面创建domains文件夹

package com.cha;

import java.io.BufferedReader;

import java.io.DataOutputStream;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.net.URL;

import java.security.AllPermission;

import java.util.ArrayList;

import java.util.List;

import java.util.UUID;

public class Cha {

final char[] String = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',

'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',

'x', 'y', 'z', };

/**

* @param args

* @throws Exception

*/

public static void main(String[] args) throws Exception {

final Cha c = new Cha();

//开启查询线程

new Thread(new Runnable() {

@Override

public void run() {

c.aillTaskList();

}

}).start();

//开启写文件线程

new Thread(new Runnable() {

@Override

public void run() {

try {

while(true){

c.saveFile();

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}).start();

}

private void aillTaskList() {

new Thread(new Runnable() {

@Override

public void run() {

//3个for循环 表示三位字母的。

for (int i = 0; i < String.length; i++) {

for (int j = 0; j < String.length; j++) {

for (int k = 0; k < String.length; k++) {

String domain = String[i] + "" + String[j]

+ String[k];

try {

System.out.println(domain);

chaIt(domain);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

}

}

}).start();

}

List domainList = new ArrayList();

StringBuffer sb = new StringBuffer();

/**

*

* @param domain 域名内容 比如 www.ij2ee.com

* @throws Exception

*/

private void chaIt(String domain) throws Exception {

//这种查是否被注册的url 大家自己找 比如

String url = "http://www.xxxx.com/cgi-bin/domainquery.cgi?flag=1&domainname="+ domain ;

URL u = new URL(url);

String res = readInputStream(u.openStream(), "UTF-8");

if (res.endsWith("1")) {

domainList.add(res);

}

}

public int delay = 1000;

private void saveFile() throws Exception {

//减少本机压力 睡眠一会儿

Thread.sleep(delay);

System.out.println("domainList.size = "+domainList.size());

if (domainList.size() >= 10) {

for (String d : domainList) {

sb.append(d).append(",");

}

saveFile(sb.toString());

// sb =new StringBuffer();

domainList.clear();

delay = 1000;

} else {

delay = 5000;

}

}

//默认保存在domains下。

void saveFile(String data) throws Exception {

String filePath = "D:\\\\domains\\\\" + UUID.randomUUID().toString()

+ ".txt";

File f = new File(filePath);

if (!f.exists()) {

f.createNewFile();

}

FileOutputStream fOut = new FileOutputStream(filePath);

DataOutputStream out = new DataOutputStream(fOut);

out.writeUTF(data);

out.flush();

out.close();

}

public static String readInputStream(InputStream is, String encode)

throws IOException {

if (encode == null) {

encode = "UTF-8";

}

BufferedReader in = new BufferedReader(

new InputStreamReader(is, encode));

StringBuffer buffer = new StringBuffer();

String line;

int isFrist = 0;

while ((line = in.readLine()) != null) {

// System.out.println(line);

buffer.append(line);

}

is.close();

return buffer.toString();

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值