相思资源网 Design By www.200059.com
利用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("https://www.jb51.net/logos.gif",Server.MapPath("google.gif"))
%>
</body>
</html>
复制代码 代码如下:
<!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("https://www.jb51.net/logos.gif",Server.MapPath("google.gif"))
%>
</body>
</html>
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无利用MSXML2.XmlHttp和Adodb.Stream采集图片的评论...