Exemplo n.º 1
0
        public static string CheckPR(string m_Url)
        {
            string text  = "http://toolbarqueries.google.com/search?client=navclient-auto&googleip=O;937&ie=UTF-8&oe=UTF-8&features=Rank&ch=" + OutputCheckSum(m_Url, 1) + "&q=info:" + m_Url;
            string text2 = CaiJi.GetHtmlSource(text);

            if (text2.Length < 20)
            {
                Regex  regex = new Regex("Rank_(?:[0-9]):(?:[0-9]):(?<PageRank>[0-9]+)");
                string value = regex.Match(text2).Groups["PageRank"].ToString();

                value = value.Length == 0 ? "0" : value;
                return(value);
            }
            return("-1");
        }
Exemplo n.º 2
0
        void BuildDG()
        {
            Regex  re;
            string Pattern;

            //取本站的链接并筛选出友情链接块
            string tempstr = CaiJi.GetHtmlSource(txtMyURL.Text);

            Pattern = "<a[^<>]+href\\s*=\\s*[\"']*" + txtS.Text + @"[\s\S]+" + txtD.Text + "[^<>]*?>[\\s\\S]+?</a>";
            re      = new Regex(Pattern, RegexOptions.IgnoreCase);
            Match match = re.Match(tempstr);

            tempstr = match.Value;

            //从友情链接块里取出链接地址及链接名称
            Pattern = "<a[^<>]+href\\s*=\\s*[\"']*([^<>\"' ]+/*)[\"']*[^<>]*?>([\\s\\S]+?)</a>";
            re      = new Regex(Pattern, RegexOptions.IgnoreCase);
            MatchCollection matchs = re.Matches(tempstr);

            foreach (Match m in matchs)
            {
                this.dataGridView1.Rows.Add(m.Groups[2].Value, m.Groups[1].Value);
            }
        }
Exemplo n.º 3
0
        public void ThreadProc()
        {
            try
            {
                bool   flags   = false;
                string tempstr = "";
                string myurl   = txtMyURL.Text.Trim();
                string mydomain;
                if (myurl.Substring(myurl.Length - 1) == "/")
                {
                    myurl = myurl.Substring(0, myurl.Length - 1);
                }
                mydomain = myurl;
                mydomain = Regex.Match(mydomain, "http://[^/]+").Value;

                //友情链接检测工具http://regexlib.com/RETester.aspx
                //<a[^<>]+href\s*=\s*["']*([^"' ]*)["']*[^<>]*?>([\s\S]+?)</a>
                // <a[\s\S]*?href=("(?<href>[^"]*)"|'(?<href>[^']*)'|(?<href>[^>\s]*))[^>]*?>(?<title>[\s\S]*?)</a>
                // @"<a[\s\S]*?href=(""(?<href>[^""]*)""|'(?<href>[^']*)'|(?<href>[^>\s]*))[^>]*?>(?<title>[\s\S]*?)</a>",RegexOptions.IgnoreCase   |   RegexOptions.Compiled);
                //string pattion = "<a[^<>]+href\\s*=\\s*[\"']*(" + mydomain + "/*)[\"']*[^<>]*?>([\\s\\S]+?)</a>";
                //string pattion = @"<a[\s\S]+?href=(""[^""]*"")|('[^']*')|([^>\s]*)[^>]*?>[\s\S]*?</a>";

                string pattion = "<a[^<>]+href\\s*=\\s*[\"']*(\"" + mydomain + "/*\")|('" + mydomain + "/*')|(" + mydomain + "/*)[^<>]*?>([\\s\\S]+?)</a>";

                for (int i = 0; i < this.dataGridView1.RowCount; i++)
                {
                    if (Convert.ToBoolean(this.dataGridView1.Rows[i].Cells["blFlag"].Value) != true)
                    {
                        flags = true;
                        string nowurl;

                        this.dataGridView1.Rows[i].Cells["blFlag"].Value = !Convert.ToBoolean(this.dataGridView1.Rows[i].Cells["blFlag"].Value);

                        nowurl  = Convert.ToString(this.dataGridView1.Rows[i].Cells["txtWebURL"].Value).ToLower();
                        tempstr = CaiJi.GetHtmlSource(nowurl);



                        if (Regex.IsMatch(tempstr, pattion, RegexOptions.IgnoreCase))
                        {
                            this.dataGridView1.Rows[i].Cells["txtStatus"].Value = "正常";
                        }
                        else
                        {
                            this.dataGridView1.Rows[i].Cells["txtStatus"].Value = "不正常";
                        }
                        if (chkPR.Checked)
                        {
                            this.dataGridView1.Rows[i].Cells["txtPR"].Value = PageRank.GetGooglePR(nowurl);
                        }
                    }
                }

                if (flags)
                {
                    ThreadProc();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }