狠狠色丁香婷婷综合尤物/久久精品综合一区二区三区/中国有色金属学报/国产日韩欧美在线观看 - 国产一区二区三区四区五区tv

LOGO OA教程 ERP教程 模切知識(shí)交流 PMS教程 CRM教程 開(kāi)發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

用ASP編寫(xiě)下載網(wǎng)頁(yè)中所有資源的程序

admin
2010年8月19日 23:53 本文熱度 3091
看過(guò)一篇關(guān)于下載網(wǎng)頁(yè)中圖片的文章,它只能下載以http頭的圖片,我做了些改進(jìn),可以下載網(wǎng)頁(yè)中的所有連接資源,并按照網(wǎng)頁(yè)中的目錄結(jié)構(gòu)建立本地目錄,存放資源。

  download.asp?url=你要下載的網(wǎng)頁(yè)

  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)'中文文件名轉(zhuǎn)換
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

Function bytes2BSTR(vIn)
dim strReturn
dim i,ThisCharCode,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function

function getFileName(byval filename)
if instr(filename,"/")>0 then
fileExt_a=split(filename,"/")
getFileName=lcase(fileExt_a(ubound(fileExt_a)))
if instr(getFileName,"?")>0 then
getFileName=left(getFileName,instr(getFileName,"?")-1)
end if
else
getFileName=filename
end if
end function

function getHTTPstr(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
getHTTPstr=Http.responseBody
set http=nothing
if err.number<>0 then err.Clear
end function


Function CreateDIR(ByVal LocalPath) '建立目錄的程序,如果有多級(jí)目錄,則一級(jí)一級(jí)的創(chuàng)建
 On Error Resume Next
 LocalPath = Replace(LocalPath, "\", "/")
 Set FileObject = server.CreateObject("Scripting.FileSystemObject")
 patharr = Split(LocalPath, "/")
 path_level = UBound(patharr)
 For I = 0 To path_level
  If I = 0 Then pathtmp = patharr(0) & "/" Else pathtmp = pathtmp & patharr(I) & "/"
   cpath = Left(pathtmp, Len(pathtmp) - 1)
  If Not FileObject.FolderExists(cpath) Then FileObject.CreateFolder cpath
 Next
 Set FileObject = Nothing
 If Err.Number <> 0 Then
  CreateDIR = False
  Err.Clear
 Else
  CreateDIR = True
 End If
End Function

function GetfileExt(byval filename)
 fileExt_a=split(filename,".")
 GetfileExt=lcase(fileExt_a(ubound(fileExt_a)))
end function

function getvirtual(str,path,urlhead)
 if left(str,7)="http://" then
  url=str
 elseif left(str,1)="/" then
  start=instrRev(str,"/")
  if start=1 then
   url="/"
  else
   url=left(str,start)
  end if
  url=urlhead&url
  elseif left(str,3)="../" then
  str1=mid(str,inStrRev(str,"../")+2)
  ar=split(str,"../")
  lv=ubound(ar)+1
  ar=split(path,"/")
  url="/"
  for i=1 to (ubound(ar)-lv)
   url=url&ar(i)
  next
  url=url&str1
  url=urlhead&url
 else
  url=urlhead&str
 end if
 getvirtual=url
end function
'示例代碼
dim dlpath

virtual="/downweb/"
truepath=server.MapPath(virtual)
if request("url")<> "" then
 url=request("url")
 fn=getFileName(url)
 urlhead=left(url,(instr(replace(url,"http://",""),"/")+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,"http://","**")
  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><br>"
  SaveToFile getRet,temp&filename
 end if
Next
set Matches=nothing
end if

%>

該文章在 2010/8/19 23:53:03 編輯過(guò)
關(guān)鍵字查詢(xún)
相關(guān)文章
正在查詢(xún)...
點(diǎn)晴ERP是一款針對(duì)中小制造業(yè)的專(zhuān)業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國(guó)內(nèi)大量中小企業(yè)的青睞。
點(diǎn)晴PMS碼頭管理系統(tǒng)主要針對(duì)港口碼頭集裝箱與散貨日常運(yùn)作、調(diào)度、堆場(chǎng)、車(chē)隊(duì)、財(cái)務(wù)費(fèi)用、相關(guān)報(bào)表等業(yè)務(wù)管理,結(jié)合碼頭的業(yè)務(wù)特點(diǎn),圍繞調(diào)度、堆場(chǎng)作業(yè)而開(kāi)發(fā)的。集技術(shù)的先進(jìn)性、管理的有效性于一體,是物流碼頭及其他港口類(lèi)企業(yè)的高效ERP管理信息系統(tǒng)。
點(diǎn)晴WMS倉(cāng)儲(chǔ)管理系統(tǒng)提供了貨物產(chǎn)品管理,銷(xiāo)售管理,采購(gòu)管理,倉(cāng)儲(chǔ)管理,倉(cāng)庫(kù)管理,保質(zhì)期管理,貨位管理,庫(kù)位管理,生產(chǎn)管理,WMS管理系統(tǒng),標(biāo)簽打印,條形碼,二維碼管理,批號(hào)管理軟件。
點(diǎn)晴免費(fèi)OA是一款軟件和通用服務(wù)都免費(fèi),不限功能、不限時(shí)間、不限用戶(hù)的免費(fèi)OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved