把文章内容中涉及到的图片自动保存到本地服务器
2004-09-13 12:02
579 查看
<%
'函数功能:把文章内容中涉及到的图片自动保存到本地服务器。(注意:请先在目录下创建tempfile目录,用来保存临时图片)
'作者:小灰
'QQ:103895
'主页:http://asp2004.net
'2004.9.13
'转载或使用请不要删除上面这些信息。谢谢!
const savepath="tempfile/"
function myreplace(str)
newstr=str
set objregEx = new RegExp
objregEx.IgnoreCase = true
objregEx.Global = true
objregEx.Pattern = "http://(.+?)/.(jpg|gif|png|bmp)"
set matches = objregEx.execute(str)
for each match in matches
newstr=replace(newstr,match.value,saveimg(match.value))
next
myreplace=newstr
end function
function saveimg(url)
temp=split(url,".")
randomize
ranNum=int(90000*rnd)+10000
filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&temp(ubound(temp))
set xmlhttp=server.createobject("Microsoft.XMLHTTP")
xmlhttp.open "get",url,false
xmlhttp.send
if xmlhttp.status<>200 then
saveimg=""
else
img=xmlhttp.ResponseBody
set objAdostream=server.createobject("ADODB.Stream")
objAdostream.Open()
objAdostream.type=1
objAdostream.Write(img)
objAdostream.SaveToFile(server.mappath("./"&savepath&filename))
objAdostream.SetEOS
set objAdostream=nothing
saveimg=savepath&filename
end if
set xmlhttp=nothing
end function
%>
'函数功能:把文章内容中涉及到的图片自动保存到本地服务器。(注意:请先在目录下创建tempfile目录,用来保存临时图片)
'作者:小灰
'QQ:103895
'主页:http://asp2004.net
'2004.9.13
'转载或使用请不要删除上面这些信息。谢谢!
const savepath="tempfile/"
function myreplace(str)
newstr=str
set objregEx = new RegExp
objregEx.IgnoreCase = true
objregEx.Global = true
objregEx.Pattern = "http://(.+?)/.(jpg|gif|png|bmp)"
set matches = objregEx.execute(str)
for each match in matches
newstr=replace(newstr,match.value,saveimg(match.value))
next
myreplace=newstr
end function
function saveimg(url)
temp=split(url,".")
randomize
ranNum=int(90000*rnd)+10000
filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&temp(ubound(temp))
set xmlhttp=server.createobject("Microsoft.XMLHTTP")
xmlhttp.open "get",url,false
xmlhttp.send
if xmlhttp.status<>200 then
saveimg=""
else
img=xmlhttp.ResponseBody
set objAdostream=server.createobject("ADODB.Stream")
objAdostream.Open()
objAdostream.type=1
objAdostream.Write(img)
objAdostream.SaveToFile(server.mappath("./"&savepath&filename))
objAdostream.SetEOS
set objAdostream=nothing
saveimg=savepath&filename
end if
set xmlhttp=nothing
end function
%>
相关文章推荐
- asp把文章内容中涉及到的图片自动保存到本地服务器
- 用asp自动解析网页中的图片地址,并将其保存到本地服务器
- 用asp自动解析网页中的图片地址,并将其保存到本地服务器
- ASP 远程图片自动保存到本地服务器
- 用asp自动解析网页中的图片地址,并将其保存到本地服务器
- 用asp自动解析网页中的图片地址,并将其保存到本地服务器
- ASP自动解析网页中的图片地址,并将其保存到本地服务器http://epasser.aydc.com.cn/article/adp/2/content13959.html
- asp自动解析网页中的图片地址,并将其保存到本地服务器
- 远程图片自动保存到本地服务器
- php自动采集内容中带有图片地址的远程图片保存到本地
- 图片自动保存到本地服务器
- 用asp自动解析网页中的图片地址,并将其保存到本地服务器
- 用asp自动解析网页中的图片地址,并将其保存到本地服务器
- php自动保存文章内容中的图片
- tableview 加载图片时内容混乱,亲测好用,以及 图片保存到本地相册
- 微信小程序导出当前画布指定区域的内容并生成图片保存到本地相册(canvas)
- 利用whistle自动保存页面内容及做本地替换
- android 从服务器下载图片,并保存到本地
- 一个带采集远程文章内容,保存图片,生成文件等完整的采集功能
- 解决:百度编辑器UEditor,怎么将图片保存到图片服务器,或者上传到ftp服务器的问题(如果你正在用UE,这篇文章值得你看下)