alexa查询代码
alexa查询代码
<%
If request("d")="" Then
Response.Redirect "myalexa.asp?d=226511.com"
End If
on error resume next
'远程截取函数开始
Server.ScriptTimeOut=9999999
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)
dim objstream
set objstream = Server.CreateObject("ado"&"db.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
Function del(str)
str=replace(str,"<REACH RANK=""","")
str=replace(str,"""/>","")
str=replace(str," ","")
del=str
End Function
dim wd
wd=Request("d")
'截取网址
url="http://data.alexa.com/data/?cli=10&dat=snba&ver=7.0&url="&wd
wstr=getHTTPPage(url)
%>
<html><head>
<title><%=Request("d")%>的alexa综合排名查询结果</title>
<meta name="robots" content="noindex,nofollow" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="pragma" content="no-cache" />
<style type="text/css">
body{
margin:0px;COLOR:#529252;FONT-SIZE:11px;FONT-weight:bold;TEXT-DECORATION:
none; font-family:"Georgia", "Arial";}
A:link,A:visited { COLOR: #0066CC; FONT-SIZE: 12px; font-weight:bold;TEXT-
DECORATION:underline;}
A:active,A:hover{COLOR:#FF3300;FONT-SIZE: 12px; font-weight:bold;TEXT-
DECORATION: underline;}
A.alexarank:link,A.alexarank:visited { COLOR:#529252;FONT-SIZE:11px;FONT-
weight:bold;TEXT-DECORATION: none; font-family:"Georgia", "Arial";}
A.alexarank:hover,A.alexarank:active { COLOR:#FF3300;FONT-SIZE:11px;FONT-
weight:bold;TEXT-DECORATION: none; font-family:"Georgia", "Arial";}
</style>
</head>
<body leftmargin=0 topmargin=0>
<div align="center">
<a href="http://www.alexa.com/siteinfo/<%=wd%>" target=_blank
class=alexarank>
<%
'截取数据
set reg=new Regexp
reg.Multiline=True
reg.Global=Flase
reg.IgnoreCase=true
reg.Pattern="<REACH RANK=((.|n)*?)>"
Set matches = reg.execute(wstr)
For Each match1 in matches
bodypage=del(match1.Value)
Next
Set matches = Nothing
Set reg = Nothing
Response.Write bodypage
%>
</a>
</div></body></html>
补充:Php教程,Php入门