ASP Universal Collection function redundant version can save files to local _ Thieves/collection
Source: Internet
Author: User
<%
' Name: ASP Universal Collection function redundant version, to the high-quality version of the conscientious change
' Author: Liu Yong FA
' 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 With
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
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service