域名注册,抢注工具编写
首先我们准备一个词典,也就最好的域名列表,我找了最常见的英文单词列表。然后确定一个验证的网站,我选的是中国万网。
我们要做的就是从词典取出每一个词,用程序去万网测试,找到未被注册的域名列表,我选的是.com的和.cn的。运行,等待输出结果
我们要做的就是从词典取出每一个词,用程序去万网测试,找到未被注册的域名列表,我选的是.com的和.cn的。运行,等待输出结果
ublic class DomainRegist {
static public String filepath = "/opt/TestHL/result.cvs";
static public String dicPath = "/opt/TestHL/dic.txt";
/**测试某个域名是否未被注册
* @param keyword
*/
static public void testDomain(String keyword)
{
String url = "http://panda.www.net.cn/cgi-bin/Check.cgi?domain=" +keyword + "&big5=n&com=yes&cn=yes";
try
{
byte[] pageHtml = HttpUtil.getPage(url);
//将页面转成string
if(pageHtml!=null)
{
String strHtml;
try {
strHtml = new String(pageHtml, "GBK");
String[][] result = StringUtil.splitByReg(strHtml,"domain=(.*?)'>");
if(result != null )
{
for(int i=0; i< result.length;i++)
for(int j=0;j<result[i].length;j++)
CSVWriter(filepath,result[i][j]);
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
/**把结果输出到文本
* @param filePath
* @param line
*/
public synchronized static void CSVWriter(String filePath, String line) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter(filePath, true));
line = StringUtil.gbk2iso(line);
out.write(line);
out.newLine();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* @param args
*/
public static void main(String[] args) {
ArrayList<String> dic = DataDir.getSpecifiedFileData(dicPath);
for(int i=0;i<dic.size();i++){
testDomain(dic.get(i).trim());
}
}
}
static public String filepath = "/opt/TestHL/result.cvs";
static public String dicPath = "/opt/TestHL/dic.txt";
/**测试某个域名是否未被注册
* @param keyword
*/
static public void testDomain(String keyword)
{
String url = "http://panda.www.net.cn/cgi-bin/Check.cgi?domain=" +keyword + "&big5=n&com=yes&cn=yes";
try
{
byte[] pageHtml = HttpUtil.getPage(url);
//将页面转成string
if(pageHtml!=null)
{
String strHtml;
try {
strHtml = new String(pageHtml, "GBK");
String[][] result = StringUtil.splitByReg(strHtml,"domain=(.*?)'>");
if(result != null )
{
for(int i=0; i< result.length;i++)
for(int j=0;j<result[i].length;j++)
CSVWriter(filepath,result[i][j]);
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
/**把结果输出到文本
* @param filePath
* @param line
*/
public synchronized static void CSVWriter(String filePath, String line) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter(filePath, true));
line = StringUtil.gbk2iso(line);
out.write(line);
out.newLine();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* @param args
*/
public static void main(String[] args) {
ArrayList<String> dic = DataDir.getSpecifiedFileData(dicPath);
for(int i=0;i<dic.size();i++){
testDomain(dic.get(i).trim());
}
}
}