<%
'----------远程获取内容,并将内容存在本地电脑上,包括任何文件!----------
'---------------利用xmlhttp和adodb.stream-----------------
'On Error Resume Next
'-------------------------------定义输出格式-----------------------------
path=request("path")
if path ="" then
path="http://pcqc.86516.com/index.asp"
'这里定义的网址是百度,,注意一定要有文件后缀
end if
sPath = Path
if left(lcase(path),7) <> "http://" then
'-------------如果前面没有http就是本地文件,交给LocalFile处理------------
LocalFile(path)
else
'--------------------否则为远程文件,交给RemoteFile处理------------------
RemoteFile(Path)
end if
'Response.Write err.Description
'--------------处理函数-----------
sub LocalFile(Path)
'-------------------如果为本地文件则简单的跳转到该页面-------------------
'Response.Redirect Path
Response.write "发生错误!"
End Sub
Sub RemoteFile(sPath)
'-------------------------处理远程文件函数------------------------------
FileName = GetFileName(sPath)
'-------------GetFileName为把地址转换为合格的文件名过程-------------
FileName = Server.MapPath("Cache/" & FileName)
Set objFso = Server.CreateObject("Scripting.FileSystemObject")
'Response.Write fileName
if objFso.FileExists(FileName) Then
'--------------检查文件是否是已经访问过,如是,则简单跳转------------
Response.Redirect "cache/" & GetFileName(path)
Else
'----------------否则的话就先用GetBody函数读取----------------------
'Response.Write Path
t = GetBody(Path)
'-----------------用二进制方法写到浏览器上--------------------------
Response.BinaryWrite t
Response.Flush
'-----------------输出缓冲------------------------------------------
SaveFile t,GetFileName(path)
'------------------将文件内容缓存到本地路径,以待下次访问-----------
End if
Set objFso = Nothing
End Sub
Function GetBody(url)
'-----------------------本函数为远程获取内容的函数---------------------
'on error resume next
'Response.Write url
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
'----------------------建立XMLHTTP对象-----------------------------
With Retrieval
.Open "Get", url, False, "", ""
'------------------用Get,异步的方法发送-----------------------
.Send
'GetBody = .ResponseText
GetBody = .ResponseBody
'------------------函数返回获取的内容--------------------------
End With
Set Retrieval = Nothing
'response.Write err.Description
End Function
Function GetFileName(str)
'-------------------------本函数为合格化的文件名函数-------------------
str = Replace(lcase(str),"http://","")
str = Replace(lcase(str),"//","/")
str = Replace(str,"?","")
str = Replace(str,"&","")
str = Replace(str,"/","")
str = replace(str,vbcrlf,"")
GetFileName = str
End Function
sub SaveFile(str,fName)
'-------------------------本函数为将流内容存盘的函数-------------------
'on error resume next
Set objStream = Server.CreateObject("ADODB.Stream")
'--------------建立ADODB.Stream对象,必须要ADO 2.5以上版本---------
'objStream.Type = adTypeBinary
objStream.Type = 1
'-------------以二进制模式打开-------------------------------------
objStream.Open
objstream.write str
'--------------------将字符串内容写入缓冲--------------------------
'response.Write fname
'路径注意
objstream.SaveToFile "E:\webroot\pcqc\vip\UploadFile\cache\"&fName,2
'objstream.SaveToFile "d:\cache\" & fName,adSaveCreateOverWrite
'--------------------将缓冲的内容写入文件--------------------------
'response.BinaryWrite objstream.Read
objstream.Close()
set objstream = nothing
'-----------------------关闭对象,释放资源-------------------------
'response.Write err.Description
End sub
function saveimage(from,tofile)
dim geturl,objStream,imgs
geturl=trim(from)
imgs=gethttppage(geturl)'取得图片的具休内容的过程
Set objStream = Server.CreateObject("ADODB.Stream")'建立ADODB.Stream对象,必须要ADO 2.5以上版本
objStream.Type =1'以二进制模式打开
objStream.Open
objstream.write imgs'将字符串内容写入缓冲
objstream.SaveToFile server.mappath(tofile),2'-将缓冲的内容写入文件
objstream.Close()'关闭对象
set objstream=nothing
end function
%>
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 《第9层》游戏特色玩法介绍
- 刀郎.2006-刀郎【九雨天下】【WAV+CUE】
- 59.9高校生.1994-素兰万岁【上华】【WAV+CUE】
- ECHO.1991-你是爱我还是需要我(国专)【EMI百代】【WAV+CUE】
- 交错战线零课主线困难通关阵容推荐一览
- 交错战线挖掘矿场角色推荐攻略
- 命运圣契公测平民阵容怎么搭配 新手开荒平民阵容攻略
- 金梅《现代发烧的声音2》发烧碟[WAV+CUE]
- 雨果唱片-《历史录音珍藏系列-现代芭蕾舞剧·红色娘子军》2CD【WAV】
- [雨果唱片]李冰《地方民歌·戏曲系列-爱的颂歌》WAV
- 《模拟人生》真人电影官宣!玛格特·罗比担任制片人
- 《星战绝地》系列玩家数超4000万!续作表现超预期
- EA称AI是其业务核心!能提高开发效率、节约成本
- 《十年经典成名好歌 高品质最佳音乐 2CD》[WAV/分轨][1GB]
- 《8个男人的故事 2CD》[WAV/分轨][1GB]