利用MSXML2.XmlHttp和Adodb.Stream采集图片
程序员文章站
2022-05-03 12:42:20
利用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>
复制代码 代码如下:
<!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>
推荐阅读
-
利用python和ffmpeg 批量将其他图片转换为.yuv格式的方法
-
Android框架Volley之:利用Imageloader和NetWorkImageView加载图片
-
PHP利用百度ai实现文本和图片审核
-
利用python对图片和base64码进行互转(GUI可视化操作)
-
JavaSctit 利用FileReader和滤镜上传图片预览功能
-
利用phpqrcode二维码生成类库和imagecopymerge函数制拼接图片的经验
-
利用xmlhttp和adodb.stream加缓存技术下载远程Web文件
-
使用file_get_content系列函数和使用curl系列函数采集图片的性能对比
-
利用SpannableString和ImageSpan在textview中插入图片的方法
-
PHP利用GD库画图和生成验证码图片_PHP教程