利用MSXML2.XmlHttp和Adodb.Stream
复制代码 代码如下:
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ASP采集图片测试</title>
<metahttp-equiv="content-type"content="text/html;charset=utf-8"/>
</head>
<body>
<%
FunctionGethttpimg(Url)
OnErrorResumeNext
DimHttp
SetHttp=Server.Createobject("MSXML2.XmlHttp")
Http.Open"Get",Url,False
Http.Send()
IfHttp.Readystate<>4ThenExitFunction
Gethttpimg=Http.Responsebody
SetHttp=Nothing
IfErr.Number<>0ThenErr.Clear
EndFunction
SubSave2Local(From,Tofile)
DimGeturl,Objstream,Imgs
Geturl=Trim(From)
Imgs=Gethttpimg(Geturl)
SetObjstream=Server.Createobject("Adodb.Stream")
Objstream.Type=1
Objstream.Open
Objstream.WriteImgs
Objstream.SavetofileTofile,2
Objstream.Close()
SetObjstream=Nothing
'Response.Write("TheImghassaved!")
EndSub
CallSave2Local("http://www.jb51.net/logos.gif",Server.MapPath("google.gif"))
%>
</body>
</html>