| 用ASP程序调用Alexa世界排名的代码 |
|
| 作者:佚名 文章来源:本站原创 点击数: 更新时间:2008-1-13 |
<% Private Function bytes2BSTR(vIn) Dim i‚ ThischrCode‚ NextchrCode strReturn = "" For i = 1 To LenB(vIn) ThischrCode = AscB(MidB(vIn‚ i‚ 1)) If ThischrCode < &H80 Then strReturn = strReturn & Chr(ThischrCode) Else NextchrCode = AscB(MidB(vIn‚ i + 1‚ 1)) strReturn = strReturn & Chr(CLng(ThischrCode) * &H100 + CInt(NextchrCode)) i = i + 1 End If Next bytes2BSTR = strReturn End Function Function GetURL(url) Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP") With Retrieval .Open "GET"‚ url‚ False‚ ""‚ "" .Send GetURL = .ResponseText GetURL = bytes2BSTR(.Responsebody) End With Set Retrieval = Nothing End Function
'以上是使用xmlhttp读取页面代码的通用代码
Function GetAlexaRank(url) on error resume next Dim tempstr‚trueurl‚x‚keystr
trueurl = "http://www.alexa.com/data/details/traffic_details?q=&url=" & url tempstr=GetURL(trueurl)
keystr = "</td><td class=""bodyBold"" align=""center"" bgcolor=""#ffffff""><img" TempStr = split(TempStr‚keystr)(0)
x = InstrRev(TempStr‚">") + 1 TempStr = mid(TempStr‚x) if err then GetAlexaRank=err.description err.clear else GetAlexaRank=TempStr end if End Function
'以上是读取Alexa网站页面,对代码进行分析然后得到排名的数据
Dim url url="www.lepoo.com" '要查询的网址,不要加http:// Response.write(GetAlexaRank2(url)) '输出排名数据
%> |
| 文章录入:付晓波 责任编辑:付晓波 |
|
上一篇文章: ASP下载系统防盗链方法
下一篇文章: 字符串截取技术(探讨用InStrRev函数配合Right/Left函数截取字符串) |
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |