求asp.net获取google PR值代码?要最新版的
解决方案 »
- 控件
- js如何JS取GridView模板里的控件
- sqlhelper我想用这个类,在哪个文件,去哪下啊
- 未将对象引用设置到对象的实例 CheckBoxList如何解决谢谢
- 求截取一段html里的img标签的方法
- 在有验证控件的页面上想点击一个服务器端按钮不用验证控件验证,怎么办
- ********** 数据库(ciclememo nvarchar(200))字段长度是200个字符或100个汉字,我现在要知道数据库里已经有几个字符或汉字,然后再来
- 入门弱弱的问一下,ADOConnection怎么找不着了?
- 帮帮忙,这个怎么改啊。
- asp.net Response.Write()之后的语句不执行
- 求用户不能重复登陆的解决方案
- vml图形无法正常显示
/// 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;
}
/// 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;
}
多了些垃圾代码 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;
}
}
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;
}
}
}
}