%
'用ASP獲取遠(yuǎn)程目標(biāo)網(wǎng)頁指定內(nèi)容,代碼由廣州網(wǎng)站建設(shè)//www.jb51.net提供
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獲取遠(yuǎn)程網(wǎng)頁指定內(nèi)容開始
Dim wstr,str,url,start,over,dtime
a="開始內(nèi)容" 'ASP獲取目標(biāo)網(wǎng)頁內(nèi)容開始標(biāo)記
b="結(jié)束內(nèi)容" 'ASP獲取網(wǎng)頁內(nèi)容結(jié)束標(biāo)記
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獲取遠(yuǎn)程網(wǎng)頁指定內(nèi)容結(jié)束
%>
'ASP獲取遠(yuǎn)程網(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="https://www.jb51.net/"
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
以上就是asp獲取遠(yuǎn)程網(wǎng)頁的指定內(nèi)容的實(shí)現(xiàn)代碼的詳細(xì)內(nèi)容,更多關(guān)于獲取遠(yuǎn)程網(wǎng)頁內(nèi)容的資料請關(guān)注腳本之家其它相關(guān)文章!