在web 2.0時代,很多網站采用ajax技術實現,帶來較好用戶體驗的代價是,javascript得到的內容搜索引擎無法爬到,google也正在研究此種技術。本文討論asp.net程序生成的鏈接,爬蟲如何能爬進去的問題。
問題:某網站出現的數據列表分頁顯示,而上一頁和下一頁都是用__dopostback提交到后臺處理,如javascript:__dopostback('ucinfolistmore$gridinfolist$_ctl21$_ctl1',''),我們根本得不到他絕對鏈接的地址,而且每一頁得下一頁傳入的參數是一樣的。
分析:我們首先理解__dopostback做了哪些事情。
function __dopostback(eventtarget, eventargument) {
var theform;
if (window.navigator.appname.tolowercase().indexof("netscape") > -1) {
theform = document.forms["form1"];//注意此處的formid
} else {
theform = document.form1;//還有此處
}
theform.__eventtarget.value = eventtarget.split("$").join(":");
theform.__eventargument.value = eventargument;
theform.submit();
}
明白了吧,問題就在.__eventtarget(后臺處理的事件)和__eventargument上。這樣就簡單了,我們可以給這兩個參數賦值,然后向后臺發送post就可以了。那么如何指定某一頁呢,asp.net在后臺是以session方式保存當前頁信息的,我們在post得時候能夠保證實在同一個會話中進行的就可以了。
新聞熱點
疑難解答
圖片精選