有谁知道这样的世界排名查询服务器端是怎么做的?

tmpx 2006-01-12 07:43:44
http://www.linkwan.com/gb/broadmeter/alexa/default.asp
...全文
37 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
jspadmin 2006-01-13
<%
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("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
%>

回复
jspadmin 2006-01-13
<!--#include file="function.asp"-->
<html>
<body onLoad="document.search.term.focus();" text="#000000" bgcolor="#FFFFFF">
<%
Dim wstr,str,url,start,over
domain=request("term")
url="http://www.alexa.com/data/details/traffic_details?q=&url="&domain
wstr=getHTTPPage(url)
start=Newstring(wstr,"<span class=""body""> Traffic Rank for")
over=Newstring(wstr,"<img alt="""" border=""0"" width=""1"" height=""10"" src=""http://client.alexa.com/common/images/shim.gif""><br>")
body=mid(wstr,start,over-start)
body=Replace(body, "<span class=""body""> Traffic Rank for ", "贵站整体排名情况=>>")
body=repalace(body,"<span class=""bodyBold"">","")
body=Replace(body, "<span class=""descBold"">", "")
body=Replace(body, "No Data", "无此站相关数据,请确认是否输错域名或改域名不存在!")
body=Replace(body, "</span>", "")
body=Replace(body, "<!--Did you know? Alexa offers this data programmatically. Visit http://webservices.amazon.com/ for more information about the Alexa Web Information Service.-->", "")

Response.Write body
%>

<form method="post" enctype="application/x-www-form-urlencoded" action="index.asp" name="search">
<input name="term" type="text" value="http://www.pifoo.com" size="30" maxlength="256">
<input value="查询排名" name="submit" type="submit">
</form>
<BR>
<a href="http://www.pifoo.com">蚍蜉中文站(http://www.pifoo.com)</a>
</body>
</html>
回复
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2006-01-12 07:43
社区公告
暂无公告