asp google pr查询代码(2)
}
function URLencode(sStr)
{
return encodeURIComponent(sStr).replace(/\+/g,"%2B").replace(/\//g,"%2F");
}
function getGoogleHostInfo(url){
var reqgr = "info:" + url;
var reqgre = "info:" + URLencode(url);
//Response.Write(reqgr+"<br>"+reqgre); 来源于网络, www.jb51.net
gch = GoogleCH(strord(reqgr));
gch = "6" + GoogleNewCh(gch);
var querystring = "http://toolbarqueries.google.com/search?client=navclient-auto&ch=" + gch + "&ie=UTF-8&oe=UTF-8&features=Rank:FVN&q=" + reqgre;
//Response.Write(querystring); 来源于网络,www.jb51.net
var objXMLHTTP, xml;
xml = Server.CreateObject("Microsoft.XMLHTTP");
xml.Open("GET", querystring, false);
xml.setRequestHeader( "User-Agent", "Mozilla/4.0 (compatible; GoogleToolbar 2.0.114-big; Windows XP 5.1)" );
xml.send();
return xml.responseText;
}
function getPageRank(temp){
var foo = temp.match(/Rank_.*?:.*?:(\d+)/i);
var pr = (foo) ? foo[1] : "";
return pr;
}
function getDirectory(temp){
var foo = temp.match(/FVN_.*?:.*?:(?:Top\/)?([^\s]+)/i);
var cat = (foo) ? foo[1] : "";
if(cat!="")cat="http://directory.google.com/Top/"+cat
return cat;
}
//来源于网络,www.jb51.net
var site;
site="www.baidu.com"; //输入站点名
if(site!="undefined"){
var google=getGoogleHostInfo(site);
var pagerank=getPageRank(google);
var directory=getDirectory(google);
Response.Write("PageRank:"+pagerank+"<br>");
Response.Write("PageRank:<img src=\"images/pr"+pagerank+".png\" alt=\"PageRank:"+pagerank+"\"><br>");
Response.Write("Site:"+site+"<br>");
if(directory!="")Response.Write("Site:<a href="+directory+">"+directory+"</a><br>");
}
%>
将上面的代码保存为pr.asp运行即可,如果想要传参,可以将
site="www.baidu.com"; //输入站点名
替换为
site=Request.QueryString("url"); //输入站点名