当前位置: 移动技术网 > IT编程>开发语言>Asp > 利用MSXML2.XmlHttp和Adodb.Stream采集图片

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

2017年12月12日  | 移动技术网IT编程  | 我要评论
利用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>  

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网