利用MSXML2.XmlHttp和Adodb.Stream采集图片
网络编程 2021-07-05 10:58www.168986.cn编程入门
asp下经常用来采集的两个组件结合使用例子
利用MSXML2.XmlHttp和Adodb.Stream
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://.w3./TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://.w3./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://.jb51./logos.gif",Server.MapPath("google.gif"))
%>
</body>
</html>
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://.w3./TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://.w3./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://.jb51./logos.gif",Server.MapPath("google.gif"))
%>
</body>
</html>
上一篇:ASP字符串转换为整形、双精度型、布尔
下一篇:ASP创建对象的两种方法比较
编程语言
- 如何快速学会编程 如何快速学会ug编程
- 免费学编程的app 推荐12个免费学编程的好网站
- 电脑怎么编程:电脑怎么编程网咯游戏菜单图标
- 如何写代码新手教学 如何写代码新手教学手机
- 基础编程入门教程视频 基础编程入门教程视频华
- 编程演示:编程演示浦丰投针过程
- 乐高编程加盟 乐高积木编程加盟
- 跟我学plc编程 plc编程自学入门视频教程
- ug编程成航林总 ug编程实战视频
- 孩子学编程的好处和坏处
- 初学者学编程该从哪里开始 新手学编程从哪里入
- 慢走丝编程 慢走丝编程难学吗
- 国内十强少儿编程机构 中国少儿编程机构十强有
- 成人计算机速成培训班 成人计算机速成培训班办
- 孩子学编程网上课程哪家好 儿童学编程比较好的
- 代码编程教学入门软件 代码编程教程