欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

利用MSXML2.XmlHttp和Adodb.Stream采集图片

程序员文章站 2024-01-13 19:55:52
利用msxml2.xmlhttp和adodb.stream 复制代码 代码如下:
利用msxml2.xmlhttp和adodb.stream
复制代码 代码如下:

<!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采集图片测试</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("//www.jb51.net/logos.gif",server.mappath("google.gif"))  
%>  
</body> 
</html>