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

 更新时间:2008年05月11日 21:36:28   作者:  
asp下经常用来采集的两个组件结合使用例子
(福利推荐:【腾讯云】服务器最新限时优惠活动,云服务器1核2G仅99元/年、2核4G仅768元/3年,立即抢购>>>:9i0i.cn/qcloud

(福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

利用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("/logos.gif",Server.MapPath("google.gif"))  
%>  
</body> 
</html>  

相关文章

最新评论

?


http://www.vxiaotou.com