网络编程
使用ASP获取Alexa排名
星期三, 02月 20th, 2008获取alexa排名其实也挺简单的,把url发送出去,然后alexa网站返回一个xml树,获取树中的//ALEXA/SD/POPULARITY节点就行了.
Function GetAlex(site)
dim url
url = “http://data.alexa.com/data/ezdy01DOo100QI?cli=10&dat=snba&ver=7.0&cdt=alx_vw=20&wid=16865&act=00000000000&ss=1024×768&bw=775&t=0&ttl=1125&vis=1&rq=2&url=” & site
dim xmlHttp
set xmlHttp=Server.createobject(”Microsoft.XMLHTTP”)
xmlHttp.open “GET”,url,false
xmlHttp.send()
dim xmlDom
set xmlDom = Server.createobject(”Microsoft.XMLDom”)
xmlDom.async = false
xmlDom.load(xmlhttp.responseXML)
if xmlDom is nothing then
set xmlDom = nothing
set xmlHttp = nothing
GetAlex = “-1″
exit Function
else
dim POPULARITY
set POPULARITY = xmlDom.documentElement.SelectSingleNode(”//ALEXA/SD/POPULARITY”)
if POPULARITY is nothing then
set POPULARITY = nothing
set xmlDom = nothing
set xmlHttp = nothing
GetAlex = “-1″
exit Function
else
GetAlex = POPULARITY.getAttribute(”TEXT”) ‘alex排名
set POPULARITY = nothing
set [...]