张靓颖个人资料和图片:如何调用显示某网站的alexa排名

来源:百度文库 编辑:高考问答 时间:2024/04/24 07:02:57
<%
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.baidu.com" '要查询的网址,不要加http://
Response.write(GetAlexaRank2(url)) '输出排名数据

%>

以上代码直接加在<td> </td>中间,怎么不行呢?
谢谢高手帮助!
只要显示排名的数字即可。

<%
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)) '输出排名数据

%>