怎樣用asp程序讀取網(wǎng)站的alexa世界排名_ASP教程
推薦:怎樣做到一個(gè)網(wǎng)站空間多個(gè)域名訪問一個(gè)網(wǎng)站空間,但是卻可以實(shí)現(xiàn)多個(gè)域名的訪問的一段ASP代碼: 以下為引用的內(nèi)容: % if Request.ServerVariables(SERVER_NAME)=&q
平時(shí)每逢alexa排名更新時(shí),我都需要將所有相關(guān)的同類網(wǎng)站的排名整理一下,看一下這些對(duì)手網(wǎng)站的排名更新情況。做的多了,也就煩了,雖然也才30多個(gè)網(wǎng)站,但一個(gè)個(gè)看下來也有點(diǎn)累。因此,想能不能用程序來讀取他的排名數(shù)據(jù)。
以前記得在什么網(wǎng)址大全的網(wǎng)站上,一個(gè)網(wǎng)站名稱后面還有這個(gè)網(wǎng)站的世界排名,相信肯定是用程序讀取的,不然要是一個(gè)個(gè)查非累死不可。但是瀏覽遍了alexa的網(wǎng)站,也沒有找到能夠直接得到排名數(shù)據(jù)的方法。雖然它提供了一些代碼,如:,但是圖片的數(shù)字就沒辦法讀取到了。
后來想要不用xmlhttp讀它頁面,然后截取出那段數(shù)字?麻煩是麻煩點(diǎn),也許可以一試。于是開始查看顯示排名的那兩頁,
| 以下為引用的內(nèi)容:
http://www.alexa.com/data/details/@url=www.itlearner.com 和 http://www.alexa.com/data/details/traffic_details@q=!amp;url=www.itlearner.com,查看源文件,搜索"traffic rank for",搜到我網(wǎng)站的排名是這樣一段代碼:<ti><bbip><traffic><today>4</today></traffic></bbip></ti>5<tprp><pyp><page views rank:><pyp>,</pyp></page views rank:></pyp></tprp><today>7</today><page views per user:><[email protected]><today>6</today></[email protected]></page views per user:><[email protected]><traffic rank for>1</traffic rank for></[email protected]>,撲通,看得這段代碼都大了,再找了一下,看到在顯示traffic rank:today 1 wk. avg. 3 mos. avg. 3 mos. change那邊,前面today和1wk都是用上面那種形式表示的,而到了3 mos也就是最關(guān)鍵的數(shù)據(jù)那邊,確是直接用數(shù)字顯示的,太好了! |
分析了一下前后的代碼,發(fā)現(xiàn)數(shù)據(jù)后面的</td><td class="bodybold" align="center" bgcolor="#ffffff"><img這段代碼是唯一的,于是開始編程工作。
下面的源代碼示例,供大家參考:
| 以下為引用的內(nèi)容:
<% private function bytes2bstr(vin) dim i, thischrcode, nextchrcode strreturn = "" for i = 1 to lenb(vin) thischrcode = ascb(midb(vin, i, 1)) if thischrcode < !amp;h80 then strreturn = strreturn !amp; chr(thischrcode) else nextchrcode = ascb(midb(vin, i 1, 1)) strreturn = strreturn !amp; chr(clng(thischrcode) * !amp;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=!amp;url=" !amp; 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網(wǎng)站頁面,對(duì)代碼進(jìn)行分析然后得到排名的數(shù)據(jù)
| 以下為引用的內(nèi)容:
dim url url="www.itlearner.com" 要查詢的網(wǎng)址,不要加http:// response.write(getalexarank2(url)) 輸出排名數(shù)據(jù) %> |
嘿嘿,以后公司的相關(guān)網(wǎng)站排名,就不用再一個(gè)一個(gè)去查了,只需要把那些網(wǎng)站依此放在程序里,就可以讓程序一個(gè)一個(gè)的讀出來了。
分享:怎樣隱藏圖片的真實(shí)地址一般情況下,網(wǎng)站的圖片代碼是這樣的。 以下為引用的內(nèi)容: img src=./attachments/test.jpg />
- asp FSO 讀寫文件本文件實(shí)現(xiàn)代碼
- asp中isNull、isEmpty和空字符串的區(qū)別
- asp獲取用戶真實(shí)IP地址的方法
- asp連接sqlserver數(shù)據(jù)庫實(shí)現(xiàn)代碼
- asp中正則表達(dá)式過濾html代碼函數(shù)
- asp中g(shù)et post提交表單區(qū)別
- 網(wǎng)頁模板:ASP內(nèi)建對(duì)象Request
- xmlhttp的open方法使用詳解
- ASP的常用的自定義函數(shù)大全
- asp中用for循環(huán)的一個(gè)小技巧
- eWebEditor v3.8 列目錄
- ASP無組件分頁實(shí)現(xiàn)思路及代碼
- 相關(guān)鏈接:
- 教程說明:
ASP教程-怎樣用asp程序讀取網(wǎng)站的alexa世界排名
。