欢迎光临
我们一直在努力

教你一次下载网页中的所有资源-ASP教程,ASP应用

建站超值云服务器,限时71元/月

看过一篇关于下载网页中图片的文章,它只能下载以http头的图片,我做了些改进,可以下载网页中的所有连接资源,并按照网页中的目录结构建立本地目录,存放资源。

download.asp?url=你要下载的网页

download.asp代码如下

<%

server.scripttimeout=9999

function savetofile(from,tofile)

on error resume next

dim geturl,objstream,imgs

geturl=trim(from)

mybyval=gethttpstr(geturl)

set objstream = server.createobject("adodb.stream")

objstream.type =1

objstream.open

objstream.write mybyval

objstream.savetofile tofile,2

objstream.close()

set objstream=nothing

if err.number<>0 then err.clear

end function

function geturlencodel(byval url)中文文件名转换

dim i,code

geturlencodel=""

if trim(url)="" then exit function

for i=1 to len(url)

code=asc(mid(url,i,1))

if code<0 then code = code + 65536

if code>255 then

geturlencodel=geturlencodel&"%"&left(hex(code),2)&"%"&right(hex(code),2)

else

geturlencodel=geturlencodel&mid(url,i,1)

end if

next

end function

function gethttppage(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

gethttppage=bytes2bstr(http.responsebody)

set http=nothing

if err.number<>0 then err.clear

end function

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 教你一次下载网页中的所有资源-ASP教程,ASP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章