asp獲取遠程網(wǎng)頁的指定內(nèi)容的實現(xiàn)代碼
更新時間:2010年10月18日 10:25:51 投稿:mdxy-dxy
用ASP獲取遠程網(wǎng)頁的指定內(nèi)容,可以輕易獲取到別人網(wǎng)頁的指定的某些內(nèi)容,其實也就是ASP小偷程序原理了,需要的朋友可以參考下。
核心函數(shù)代碼如下:
<% '用ASP獲取遠程目標網(wǎng)頁指定內(nèi)容,代碼由廣州網(wǎng)站建設(shè)//chabaoo.cn提供 On Error Resume Next Server.ScriptTimeOut=9999999 Function getHTTPPage(Path) t = GetBody(Path) getHTTPPage=BytesToBstr(t,"GB2312") End function Function Newstring(wstr,strng) Newstring=Instr(lcase(wstr),lcase(strng)) if Newstring<=0 then Newstring=Len(wstr) 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 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 'ASP獲取遠程網(wǎng)頁指定內(nèi)容開始 Dim wstr,str,url,start,over,dtime a="開始內(nèi)容" 'ASP獲取目標網(wǎng)頁內(nèi)容開始標記 b="結(jié)束內(nèi)容" 'ASP獲取網(wǎng)頁內(nèi)容結(jié)束標記 url="http://sc.jb51.net/" wstr=getHTTPPage(url) start=Newstring(wstr,a) over=Newstring(wstr,b) body=mid(wstr,start,over-start) response.write ""&body&"" '輸出獲取到的網(wǎng)頁內(nèi)容 'ASP獲取遠程網(wǎng)頁指定內(nèi)容結(jié)束 %>
上面的代碼可以獲取指定網(wǎng)頁的內(nèi)容,如果是全部獲取就更簡單了
代碼如下:
'ASP獲取遠程網(wǎng)頁指定內(nèi)容開始 Dim wstr,str,url,start,over,dtime url="http://sc.jb51.net/" wstr=getHTTPPage(url) body=wstr
如果想將代碼保存到本地
Dim wstr,str,url,start,over,dtime url="http://chabaoo.cn/" wstr=getHTTPPage(url) filename="index.htm" if wstr<>"" and request("action")="makeindex" then body=wstr Set fso = Server.CreateObject("Scripting.FileSystemObject") Set fout = fso.CreateTextFile(server.mappath(""&filename&"")) fout.Write body fout.close set fout=nothing set fso=nothing If Err.number=0 then response.write("<div class=""tishi"">首頁生成成功??!</div>") end if end if
具體的大家可以根據(jù)需要自行修改即可。
以上就是asp獲取遠程網(wǎng)頁的指定內(nèi)容的實現(xiàn)代碼的詳細內(nèi)容,更多關(guān)于獲取遠程網(wǎng)頁內(nèi)容的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
獨孤劍寫的馬克斯迅雷片庫采集插件1.4 官方最新版提供下載了
非常不錯的采集迅雷插件,經(jīng)本人測試非常不錯,而且作者很熱心,是個好人,希望大家支持下,不要拿去賣了。2008-01-01實例講解實現(xiàn)抓取網(wǎng)上房產(chǎn)信息的ASP程序
實例講解實現(xiàn)抓取網(wǎng)上房產(chǎn)信息的ASP程序...2007-03-03利用MSXML2.XmlHttp和Adodb.Stream采集圖片
asp下經(jīng)常用來采集的兩個組件結(jié)合使用例子2008-05-05