加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

一次性下载远程页面上的全部内容第1 2页

发布时间:2023-04-06 12:50:02 所属栏目:Asp教程 来源:
导读:一次性下载远程页面上的所有内容使用方法,将上面的代码保存为一个比如:downfile.asp<%&#39;设置超时的时间Server.ScriptTimeout=9999&#39;##############&#39;文件保存函数&#39;#############function SaveToFile(fr

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

使用方法,将上面的代码保存为一个比如:downfile.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

'##############

'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.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

'##############

'XML获取远程页面结束,这段是小偷程序都通用的部分

'##############

'分解地址,取得文件名

'#############

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

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章