求asp.net获取google PR值代码?要最新版的

解决方案 »

  1.   

    /// <summary>
            /// Google
            /// </summary>
            /// <returns></returns>
            public int getGoogle()
            {
                string strUrl = "http://www.google.cn/search?complete=1&hl=zh-CN&meta=&q=site%3A" + this.Url;
                NetHelper text = new NetHelper();
                text.TimeOut = 1000;
                string str  = 采集网页的html
                if (return2.State != 1)
                {
                    return -1;
                }
                string str2 = strForm2S( str  "约有 <b>", "</b> 项符合").Replace(",", "");
                try
                {
                    return Convert.ToInt32(str2);
                }
                catch
                {
                    return -1;
                }
            }        public static string strForm2S(string sstr, string s, string e)
            {
                string str = "";
                int index = sstr.IndexOf(s, 0);
                if (index >= 0)
                {
                    int num2 = sstr.IndexOf(e, index);
                    if (num2 >= 0)
                    {
                        str = sstr.Substring(index + s.Length, (num2 - index) - s.Length);
                    }
                }
                return str;
            }
      

  2.   

    /// <summary>
            /// Google
            /// </summary>
            /// <returns></returns>
            public int getGoogle()
            {
                string strUrl = "http://www.google.cn/search?complete=1&hl=zh-CN&meta=&q=site%3A" + this.Url;
                NetHelper text = new NetHelper();
                text.TimeOut = 1000;
                string str  = 采集网页的html
                if (return2.State != 1)
                {
                    return -1;
                }
                string str2 = strForm2S( str  "约有 <b>", "</b> 项符合").Replace(",", "");
                try
                {
                    return Convert.ToInt32(str2);
                }
                catch
                {
                    return -1;
                }
            }        public static string strForm2S(string sstr, string s, string e)
            {
                string str = "";
                int index = sstr.IndexOf(s, 0);
                if (index >= 0)
                {
                    int num2 = sstr.IndexOf(e, index);
                    if (num2 >= 0)
                    {
                        str = sstr.Substring(index + s.Length, (num2 - index) - s.Length);
                    }
                }
                return str;
            }
      

  3.   

    错了。
    多了些垃圾代码 public int getGoogle() 
            { 
                string strUrl = "http://www.google.cn/search?complete=1&hl=zh-CN&meta=&q=site%3A" + this.Url; 
                string str  = 采集网页的html 
                string str2 = strForm2S( str  "约有 <b>", " </b> 项符合").Replace(",", ""); 
                try 
                { 
                    return Convert.ToInt32(str2); 
                } 
                catch 
                { 
                    return -1; 
                } 
            } 
      

  4.   

    取保到值呀using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.IO;
    using System.Net;
    using System.Text;namespace test
    {
        public partial class PRAlexa : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {        }        protected void Button1_Click(object sender, EventArgs e)
            {
                Label1.Text = "Alexa:" + getAlexa() + "<>Google Pr:" + getGoogle();
            }
            public int getAlexa() 
            { 
                string strUrl = "http://data.alexa.com/data/+wQ411en8000lA?cli=10&dat=snba&ver=7.0&cdt=alx_vw=20&wid=12206&act=00000000000&ss=1680x1050&bw=964&t=0&ttl=35371&vis=1&rq=4&url=http://" + TextBox1.Text;
                string txt = "";
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strUrl);
                HttpWebResponse myResponse = (HttpWebResponse)request.GetResponse();
                if (myResponse.StatusDescription.ToString().ToUpper() == "OK")
                {
                    Stream streamReceive = myResponse.GetResponseStream();
                    StreamReader streamReader = new StreamReader(streamReceive, Encoding.UTF8);
                    txt = streamReader.ReadToEnd();
                }
                string str2 = strForm2S(strForm2S(txt , " <POPULARITY", " <RANK DELTA"), "TEXT=\"", "\"/>").Replace(",", "");
                //Response.Write(txt);
                if (str2.Length == 0) 
                { 
                    return 0; 
                } 
                try 
                { 
                    return Convert.ToInt32(str2); 
                } 
                catch 
                { 
                    return -1; 
                } 
            }
            public static string strForm2S(string sstr, string s, string e)
            {
                string str = "";
                int index = sstr.IndexOf(s, 0);
                if (index >= 0)
                {
                    int num2 = sstr.IndexOf(e, index);
                    if (num2 >= 0)
                    {
                        str = sstr.Substring(index + s.Length, (num2 - index) - s.Length);
                    }
                }
                return str;
            }        public int getGoogle() 
            { 
                string strUrl = "http://www.google.cn/search?complete=1&hl=zh-CN&meta=&q=site%3A" + TextBox1.Text;
                string str  = "";
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strUrl);
                HttpWebResponse myResponse = (HttpWebResponse)request.GetResponse();
                if (myResponse.StatusDescription.ToString().ToUpper() == "OK")
                {
                    Stream streamReceive = myResponse.GetResponseStream();
                    StreamReader streamReader = new StreamReader(streamReceive, Encoding.UTF8);
                    str = streamReader.ReadToEnd();
                }
                string str2 = strForm2S( str,"约有 <b>", " </b> 项符合").Replace(",", "");
                //Response.Write("::goolepr::"+str);
                try 
                { 
                    return Convert.ToInt32(str2); 
                } 
                catch 
                { 
                    return -1; 
                } 
            }
        }
    }
      

  5.   

    c# asp.net获取google pr值源代码 
      

  6.   

    兄弟们 我咋感觉你们弄的是 google收录呢