ExtraGain

07蓄势,08翱翔
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

域名批量查询系统

Posted on 2007-12-19 17:20  ExtraGain  阅读(958)  评论(0)    收藏  举报

域名注册查询系统
本代码主要是查询26个英文字母加10个数字组成的1到3位的.cn域名,可自行更改
查询较多时,请把超时时间设大一点。

大概思路就是这样的,还请高人完善一下。


 

 

 1using System;
 2using System.Data;
 3using System.Configuration;
 4using System.Collections;
 5using System.Web;
 6using System.Web.Security;
 7using System.Web.UI;
 8using System.Web.UI.WebControls;
 9using System.Web.UI.WebControls.WebParts;
10using System.Web.UI.HtmlControls;
11using System.Net;
12using System.Net.Sockets;
13using System.Text;
14using System.IO;
15using log4net;
16using ClassLibrary1;
17
18public partial class post : System.Web.UI.Page
19{
20    private const string CST_DEFAULT_ENCODEING = "GB2312";
21    protected void Page_Load(object sender, EventArgs e)
22    {
23        sentHttp();
24    }

25    private void sentHttp()
26    {
27        string result = "";
28        string[] temp = new string[]{"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o",
29            "p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9",""}
;
30        for (int i = 0; i < 36; i++)
31        {
32            for (int j = 0; j < 36; j++)
33            {
34                for (int l = 18; l < 36; l++)
35                {
36                    result = GetWebPageString("http://panda.www.net.cn/cgi-bin/check_ac2.cgi?domain=" + temp[i]+temp[j]+temp[l] + ".cn");
37                    if (result.Contains("|210|"))
38                    {                      
39                        Class1.writeLog(result);
40                    }

41                }

42            }

43        }

44    }

45
46
47    /// <summary>
48    /// 使用Get方式得到数据
49    /// </summary>
50    /// <param name="URL">URL地址</param>
51    /// <returns>网页输出的内容</returns>

52    public static string GetWebPageString(string URL)
53    {
54        Stream data = null;
55        try
56        {
57            string str = "";
58            string sReturn = "";
59            // Get HTML data                    
60            WebClient client = new WebClient();
61
62            data = client.OpenRead(URL);
63            StreamReader reader = new StreamReader(data, System.Text.Encoding.GetEncoding(CST_DEFAULT_ENCODEING));
64
65            str = reader.ReadLine();
66
67            while (str != null)
68            {
69                sReturn += str;
70                str = reader.ReadLine();
71            }

72            return sReturn;
73        }

74        catch (Exception ex)
75        {
76            throw ex;
77        }

78        finally
79        {
80            if (data != null) data.Close();
81        }

82    }

83}

84