首页 > 网站 > 建站经验 > 正文

一次性下载远程页面上的所有内容第2/2页

2019-11-02 14:08:01
字体:
来源:转载
供稿:网友


'示例代码

dim dlpath
'建立一个文件夹,以便存放这些获取的数据
virtual="/downweb/"
truepath=server.MapPath(virtual)

if request("url")<> "" then
url=request("url")
fn=getFileName(url)
urlhead=left(url,(instr(replace(url,"//",""),"/")+1))
urlpath=replace(left(url,instrRev(url,"/")),urlhead,"")
strContent = getHTTPPage(url)
mystr=strContent
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "(src|href)=.[^/>]+? "
Set Matches =objRegExp.Execute(strContent)
For Each Match in Matches
str=Match.Value
str=replace(str,"src=","")
str=replace(str,"href=","")
str=replace(str,"""","")
str=replace(str,"'","")
filename=GetfileName(str)
getRet=getVirtual(str,urlpath,urlhead)
temp=Replace(getRet,"//","**")
start=instr(temp,"/")
endt=instrRev(temp,"/")-start+1
if start>0 then
repl=virtual&mid(temp,start)&" "
'response.Write repl&"<br>"
mystr=Replace(mystr,str,repl)

dir=mid(temp,start,endt)
temp=truepath&Replace(dir,"/","/")
CreateDir(temp)
response.Write getRet&"||"&temp&filename&"<br>"
response.Write "成功取得"&filename&"这个文件<br>"
response.Write "并将"&filename&"保存在"&temp&"<br><br>"
response.Write "<HR>"
SaveToFile getRet,temp&filename
end if
Next
set Matches=nothing
end if
%>

上一页12阅读全文
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表