在网页中提供alexa和pr值查询功能的代码
By  master 发表于 2006-7-20 13:55:00 [出自: 碧森尤信

【摘要】 方法一:直接在网页中嵌入代码 把下面这段代码放到你的网页中就可以有pr和alexa 查询了<form action=http://www.pipcn.com/link/?action=search&do=alexa name="form9" target="cmd" method="post"><!--begin 可修改显示样式-->网站信息:<br /><!--Begin:设定默认查询首页。……
碧森尤信 

方法一:直接在网页中嵌入代码

把下面这段代码放到你的网页中就可以有pr和alexa 查询了
<form action=http://www.pipcn.com/link/?action=search&do=alexa
name="form9" target="cmd" method="post">
<!--begin 可修改显示样式-->
网站信息:<br />
<!--Begin:设定默认查询首页。下面的 www.pipcn.com/link/ 是可修改默认的查询页面-->
http://<input name="url" type="text" size="30" value="/blog/www.pipcn.com/link/">
<!--End 设定默认查询首页-->
<br /><input  type="submit" value="ALEXA世界排名" 
onClick="javascript:window.rinfo.innerHTML='Loading...';
form9.action='http://www.pipcn.com/link/?action=search&do=alexa';form9.submit(); " />
<input  type="submit" value="Google PR值"
onClick="javascript:window.rinfo.innerHTML='Loading...';
form9.action='http://www.pipcn.com/link/?action=search&do=pr';form9.submit(); " />
</form>
<!--Begin:结果输出--> 
<div id="rinfo" name="rinfo" >Loading...</div>
<!--End:结果输出-->
<!--End 可修改显示样式-->
<iframe frameborder=0 height=0
src=http://www.pipcn.com/link/?action=search&do=alexa&url=www.pipcn.com/link/
name="cmd" id="cmd" ></iframe>

 效果显示:

网站信息:
http://
当前的Google 页面等级:PR= 3/10
查看详细信息  进入

方法二:查询pr和查询alexa的ASP函数代码

function getPR(URL)
 url="http://rankwhere.com/google-page-rank.php?url="&URL
 wstr=getHTTPPage(url)
 start=Newstring(wstr,"has Google")
 over=Newstring(wstr,"NOTE")
 body=mid(wstr,start+0,over-start-10) 
 body_arr=Split(body," ")
 Y_MyLink_PR=int(body_arr(3))
 getPR=Y_MyLink_PR
end function

function getAlexa(URL)
 url="http://www.alexa.com/data/details/traffic_details?q=&url="&URL
 wstr=getHTTPPage(url)
 start=Newstring(wstr,
"<!--Did you know? Alexa offers this data programmatically. 
Visit http://aws.amazon.com/awis for more information about the Alexa Web Information Service.-->") 
 if len(wstr)=start then
  getAlexa = 9999999
 else
  body=mid(wstr,start-0,1119)
  over=Newstring(body,"</span>")
  body=mid(wstr,start-0,over-0)
  getAlexa = RegExpTest(">[0-9]{1,3}<", body)
 end if
end function

Function getHTTPPage(Path)
        t = GetBody(Path)
        getHTTPPage=BytesToBstr(t,"GB2312")
End function

Function GetBody(url)
        on error resume next
        Set Retrieval = CreateObject("Microsoft.XMLHTTP")
        With Retrieval
        .Open "Get", url, False, "", ""
        .Send
        GetBody = .ResponseBody
        End With
        Set Retrieval = Nothing
End Function


Function BytesToBstr(body,Cset)
  on error resume next
        dim objstream
        set objstream = Server.CreateObject("adodb.stream")
        objstream.Type = 1
        objstream.Mode =3
        objstream.Open
        objstream.Write body
        objstream.Position = 0
        objstream.Type = 2
        objstream.Charset = Cset
        BytesToBstr = objstream.ReadText
        objstream.Close
        set objstream = nothing
End Function

Function Newstring(wstr,strng)
        Newstring=Instr(lcase(wstr),lcase(strng))
        if Newstring<=0 then Newstring=Len(wstr)
End Function

 小结:方法一比较简单,可以直接使用;方法二还需要编写程序代码,稍微有些烦琐,函数功能一目了然,就不解释了,但可以实现更多功能(怎么利用,自己想吧,哈哈)。

本站原创,鄙视转载不注名出处。

本站搜索: alexa pr google 代码
[在Google上搜索相关文章] [在百度上搜索相关文章]

【郑重声明】 本站所有文章除注有来源网址外均为互联网首发,按照创造共用方式授权,允许相关网站转载,但必须标明作者名称并在明显位置作好原文网址链接(复制以上链接),且不能运用于任何商业目的。
——建筑知识引擎小组 创造共用方式
 
阅读全文 | 回复(1) | 引用通告 | 编辑
Re:在网页中提供alexa和pr值查询功能的代码
By  海天网络(游客)发表评论于2006-9-12 21:50:00 

很好谢谢。

 
个人主页 | 引用 | 返回 | 删除 | 回复

本站已经关闭回复功能,如需联系本站,请发送email至CKETeam[at]gmail.com(请将email地址中的[at]改为@)。

发表评论:

    昵称:
    密码: (游客无须输入密码)
    主页:
    标题:
    数据载入中...

 
 站长公告

  碧森尤信,聚集最优秀的建筑网络资源,中文建筑知识引擎的发起者和推动者!
  本博客作为碧森尤信网站用户的官方在线服务通道;同时也作为站长交流和学习空间。

联系站长
pipcn.com[at]gmail.com

联系[建筑知识引擎小组]
CKETeam AT Gmail.com

站点日历
<< < 2006 - 7 > >>
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
最新日志
最新评论
最新留言
 站长链接

Google
互联网 碧森尤信
站点统计
日志搜索
用户登陆

 
© 2005-2006 碧森尤信.