Use msxml2.xmlhttp and ADODB. Stream to collect images
Source: Internet
Author: User
Use msxml2.xmlhttp and ADODB. Stream
CopyCode The Code is as follows: <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> Asp image acquisition test </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
</Head>
<Body>
<%
Function gethttpimg (URL)
On Error resume next
Dim HTTP
Set HTTP = server. Createobject ("msxml2.xmlhttp ")
HTTP. Open "get", URL, false
HTTP. Send ()
If HTTP. readystate <> 4 then exit function
Gethttpimg = http. responsebody
Set HTTP = nothing
If err. Number <> 0 then err. Clear
End Function
Sub 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
'Response. Write ("the IMG has saved! ")
End sub
Call save2local ("http://www.jb51.net/logos.gif", server. mappath ("google.gif "))
%>
</Body>
</Html>
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