Exemple #1
0
 private void ResolveIPAddress(IList <BaiDuResultInfo> resultList)
 {
     try
     {
         BaiDuResultInfo origin = resultList[resultList.Count - 1];
         IPAddress[]     ips    = Dns.GetHostAddresses(origin.Url);
         if (ips.Length == 0)
         {
             resultList[resultList.Count - 1].IP = "未知";
         }
         else if (ips.Length == 1)
         {//单IP
             resultList[resultList.Count - 1].IP = ips[0].ToString();
         }
         else
         {
             resultList[resultList.Count - 1].IP = ips[0].ToString();
             for (int i = 1; i < ips.Length; i++)
             {
                 BaiDuResultInfo bdri = new BaiDuResultInfo();
                 bdri.ID       = origin.ID;
                 bdri.Type     = origin.Type;
                 bdri.Title    = "";
                 bdri.Url      = "";
                 bdri.IP       = ips[i].ToString();
                 bdri.RowIndex = rowIndex++;
                 resultList.Add(bdri);
             }
         }
     }
     catch
     {
         resultList[resultList.Count - 1].IP = "未知";
     }
 }
Exemple #2
0
        void ProcessUrls(object p)
        {
            IList <BaiDuResultInfo> resultList = new List <BaiDuResultInfo>();
            int index = 1;

            string urls = p as string;

            string[] urlList = urls.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string url in urlList)
            {
                BaiDuResultInfo bdri = new BaiDuResultInfo();
                bdri.ID = index++;
                //  bdri.Title = m.Groups[2].Value.Trim();
                bdri.Url = url;
                // bdri.IP = GetIPAddress(bdri.Url);
                // bdri.Type = BaiDuResultInfo.ResultType.推广;


                bdri.RowIndex = rowIndex++;
                resultList.Add(bdri);
                ResolveIPAddress(resultList);
            }
            this.m_WorkStatus++;
            m_DataSource = resultList;
            BindData(resultList);

            Thread pingThread = new Thread(new ParameterizedThreadStart(PingServer));

            pingThread.IsBackground = true;

            pingThread.Start(resultList);
            HttpGet(resultList);
        }
Exemple #3
0
        void ResolveResult(string html, string filter)
        {
            string[]       filters    = filter.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            IList <string> filterList = new List <string>();

            foreach (string f in filters)
            {
                filterList.Add(f);
            }
            string strTuiGuang1 = "<table id=\"(\\d+)\"  width=\"65%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" bgcolor=\"#f5f5f5\".*<font size=\"3\" style=\"text\\-decoration:underline;\">(.*)</font><font size=\"-1\" color=\"#008000\" style=\"margin-left:6px;\">(.*?)</font>";

            string strTuiGuang = "<table id=\"(\\d+)\"  class=\"ec_pp_f\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">.*<font size=-1>(.*)<br><font size=-1 color=\"#008000\">(.*) \\d{4}-\\d{1,2}</font>.*</table>";
            string strResult   = "<table cellpadding=\"0\" cellspacing=\"0\" class=\"result\" id=\"(\\d+)\">.*<font size=\"3\">.*</font></a><br><font size=-1>(.*)<br><font color=\"#008000\">(.*)/? \\d{4}-\\d{1,2}-\\d{1,2}  </font>";

            Regex reTuiGuang1 = new Regex(strTuiGuang1, RegexOptions.Singleline);
            Regex reTuiGuang  = new Regex(strTuiGuang);
            Regex reResult    = new Regex(strResult);
            IList <BaiDuResultInfo> resultList = new List <BaiDuResultInfo>();

            int index = 1;



            MatchCollection mcTuiGuang1 = reTuiGuang1.Matches(html);
            MatchCollection mcTuiGuang  = reTuiGuang.Matches(html);

            //推广1
            foreach (Match m in mcTuiGuang1)
            {
                BaiDuResultInfo bdri = new BaiDuResultInfo();
                bdri.ID    = index++;
                bdri.Title = m.Groups[2].Value.Trim();
                bdri.Url   = m.Groups[3].Value.Trim();
                // bdri.IP = GetIPAddress(bdri.Url);
                bdri.Type = BaiDuResultInfo.ResultType.推广;
                if (!filterList.Contains(bdri.Url) && (this.m_ShowFilter == "推广" || this.m_ShowFilter == "全部"))
                {
                    resultList.Add(bdri);
                    bdri.RowIndex = rowIndex++;
                    ResolveIPAddress(resultList);
                }
            }

            //推广
            foreach (Match m in mcTuiGuang)
            {
                BaiDuResultInfo bdri = new BaiDuResultInfo();
                bdri.ID    = index++;
                bdri.Title = m.Groups[2].Value.Trim();
                bdri.Url   = m.Groups[3].Value.Trim();
                // bdri.IP = GetIPAddress(bdri.Url);
                bdri.Type = BaiDuResultInfo.ResultType.推广;
                if (!filterList.Contains(bdri.Url) && (this.m_ShowFilter == "推广" || this.m_ShowFilter == "全部"))
                {
                    resultList.Add(bdri);
                    bdri.RowIndex = rowIndex++;
                    ResolveIPAddress(resultList);
                }
            }


            MatchCollection mcResult = reResult.Matches(html);

            //普通结果
            foreach (Match m in mcResult)
            {
                BaiDuResultInfo bdri = new BaiDuResultInfo();
                bdri.ID    = index++;
                bdri.Title = m.Groups[2].Value.Trim();
                bdri.Url   = m.Groups[3].Value.Trim();
                bdri.Type  = BaiDuResultInfo.ResultType.普通;
                if (!filterList.Contains(bdri.Url) && (this.m_ShowFilter == "普通" || this.m_ShowFilter == "全部"))
                {
                    resultList.Add(bdri);
                    bdri.RowIndex = rowIndex++;
                    ResolveIPAddress(resultList);
                }
            }

            m_DataSource = resultList;
            BindData(resultList);
            m_WorkStatus++;
            Thread pingThread = new Thread(new ParameterizedThreadStart(PingServer));

            pingThread.IsBackground = true;
            pingThread.Start(resultList);
            HttpGet(resultList);
        }
Exemple #4
0
        private void ResolveIPAddress(IList<BaiDuResultInfo> resultList)
        {
            try
            {
                BaiDuResultInfo origin = resultList[resultList.Count-1];

                IPAddress[] ips = Dns.GetHostAddresses(origin.Domain);
                if (ips.Length == 0)
                    resultList[resultList.Count - 1].IP = "未知";
                else if (ips.Length == 1)
                {//单IP
                    resultList[resultList.Count - 1].IP = ips[0].ToString();

                }
                else
                {
                    resultList[resultList.Count - 1].IP = ips[0].ToString();
                    for (int i = 1; i < ips.Length; i++)
                    {
                        BaiDuResultInfo bdri = new BaiDuResultInfo();
                        bdri.ID = origin.ID;

                        bdri.Title = "";
                        bdri.Url = "";
                        bdri.IP = ips[i].ToString();
                        bdri.RowIndex = rowIndex++;
                        resultList.Add(bdri);

                    }
                }

            }
            catch
            {
                resultList[resultList.Count - 1].IP = "未知";
            }
        }
Exemple #5
0
        void ProcessUrls(object p)
        {
            IList<BaiDuResultInfo> resultList = new List<BaiDuResultInfo>();
            int index = 1;

            string urls = p as string;
            string[] urlList = urls.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string url in urlList)
            {
                BaiDuResultInfo bdri = new BaiDuResultInfo();
                bdri.ID = index++;
              //  bdri.Title = m.Groups[2].Value.Trim();
                bdri.Url = url;
                // bdri.IP = GetIPAddress(bdri.Url);
               // bdri.Type = BaiDuResultInfo.ResultType.推广;

                 bdri.RowIndex = rowIndex++;
                 resultList.Add(bdri);
                 ResolveIPAddress(resultList);

            }
            this.m_WorkStatus++;
            m_DataSource = resultList;
            BindData(resultList);

            Thread pingThread = new Thread(new ParameterizedThreadStart(PingServer));
            pingThread.IsBackground = true;

            pingThread.Start(resultList);
            HttpGet(resultList);
        }