<%
const con="<img src=http://www.xtxdl.com/xiaohua/images/logo.gif'><br><br><strong>123笑话大全,专业建站,高质低价!QQ:1016964448.</p>"
const savepath="pic"
'判断文件夹是否存在,不存在自动创建
FilePath=Server.Mappath(savepath)
Set Fso = Server.CreateObject("Scripting.FileSystemObject")
If Not Fso.FolderExists(FilePath) Then Fso.CreateFolder (FilePath)
Set Fso = Nothing
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
response.Write myreplace(con)
%>





