国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

一次性下載遠程頁面上的所有內(nèi)容第1/2頁

2024-05-04 11:04:57
字體:
供稿:網(wǎng)友

一次性下載遠程頁面上的所有內(nèi)容
使用方法,將上面的代碼保存為一個比如:downfile.asp
在瀏覽器上輸入:
http://你的地址/downfile.asp?url=http://www.baidu.com/index.html

'設置超時的時間
Server.ScriptTimeout=9999
'##############
'文件保存函數(shù)
'#############
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.number0 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 codeIf 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
'##############
'XML獲取遠程頁面開始
'#############
function getHTTPPage(url)
on error resume next
dim http
set http=Server.createobject("Msxml2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate4 then exit function
getHTTPPage=bytes2BSTR(Http.responseBody)
set http=nothing
if err.number0 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 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
'##############
'XML獲取遠程頁面結(jié)束,這段是小偷程序都通用的部分
'#############

'##############
'分解地址,取得文件名
'#############
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

'##############
'獲取遠程頁面函數(shù)
'#############
function getHTTPstr(url)
on error resume next
dim http
set http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate4 then exit function
getHTTPstr=Http.responseBody
set http=nothing
if err.number0 then err.Clear
end function

'##############
'FSO處理函數(shù),創(chuàng)建目錄
'#############
Function CreateDIR(ByVal LocalPath) '建立目錄的程序,如果有多級目錄,則一級一級的創(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

當前1/2頁?12下一頁閱讀全文
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 旬阳县| 湖州市| 邹平县| 镇远县| 阳江市| 河津市| 清水河县| 安义县| 大名县| 筠连县| 离岛区| 临海市| 古浪县| 稷山县| 文水县| 且末县| 厦门市| 洞口县| 新龙县| 杨浦区| 白城市| 河池市| 水城县| 紫阳县| 中方县| 平舆县| 分宜县| 大洼县| 广水市| 安陆市| 瑞安市| 岑溪市| 潞城市| 宁武县| 招远市| 蛟河市| 松桃| 平罗县| 墨脱县| 石河子市| 关岭|