<%
'Name: ASP universal collection function redundancy edition, which must be edited by the product Edition
'Author: Liu yongfa
'Date: 2007-6-23
Function gethttppage (PATH)
T = getbody (PATH)
Gethttppage = bytestobstr (T, "gb2312 ")
End Function
Function getbody (URL)
On Error resume next
Set XMLHTTP = Createobject ("Microsoft. XMLHTTP ")
With XMLHTTP
. Open "get", URL, false ,"",""
. Send
. Waitforresponse 1000
Getbody =. responsebody
End
Set XMLHTTP = nothing
End Function
Function bytestobstr (body, cset)
On Error resume next
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 gethttpimg (URL)
On Error resume next
Dim XMLHTTP
Set XMLHTTP = server. Createobject ("msxml2.xmlhttp ")
XMLHTTP. Open "get", URL, false
XMLHTTP. Send ()
If XMLHTTP. Status <> 200 then exit function
Gethttpimg = XMLHTTP. responsebody
Set XMLHTTP = nothing
If err. Number <> 0 then err. Clear
End Function
Function save2local (from, tofile)
Dim geturl, objstream, IMGs
Geturl = trim (from)
IMGs = gethttpimg (geturl)
Set objstream = server. Createobject ("ADODB. Stream ")
Objstream. type = 1
Objstream. Open
Objstream. Write IMGs
Objstream. savetofile tofile, 2
Objstream. Close ()
Set objstream = nothing
End Function
%>
<%
Nowdir = server. mappath ("/")
Call save2local ("http://www.baidu.com/img/logo.gif", nowdir & "baidulogo.gif ")
Call save2local ("http://flash.jninfo.net/images/banner.swf", nowdir & "banner.swf ")
Call save2local ("http://www.jb51.net.com/", nowdir & "jb51.htmll ")
Response. Write gethttppage ("http://www.jb51.net /")
%>