您现在的位置: 无忧电子商务网 >> 信息学院 >> 程序开发 >> asp >> 正文

远程获取内容,并将内容存在本地电脑上,包括任何文件!利用xmlhttp和adodb.stream,酷!绝对原创!

作者:作者:未…    信息学院来源:网络收集    点击数:    更新时间:2006-8-27 我要参与讨论

  <%
'------------------------------------------------------------------------
'-------------------无垠网域:http://www.5inet.net/ ---------------------
'-------------------作者:嘻哈呵嘿 ,webmaster@5inet.net -----------------
'----------远程获取内容,并将内容存在本地电脑上,包括任何文件!----------
'---------------利用xmlhttp和adodb.stream,酷!绝对原创!-----------------
'On Error Resume Next
'Set the content type to the specific type that you are sending.
'Response.ContentType = "IMAGE/JPEG"
'-------------------------------定义输出格式-----------------------------

Path=request.querystring("p")
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
End Sub

Sub RemoteFile(sPath)
'-------------------------处理远程文件函数------------------------------
    FileName = GetFileName(sPath)
    '-------------GetFileName为把地址转换为合格的文件名过程-------------
    FileName = Server.MapPath("/UploadFile/Cache/" & FileName)
    Set objFso = Server.CreateObject("Scripting.FileSystemObject")
    'Response.Write fileName
    if objFso.FileExists(FileName) Then
    '--------------检查文件是否是已经访问过,如是,则简单跳转------------
        Response.Redirect "/uploadfile/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对象----------------------

[1] [2] 下一页

在google里搜索更多远程获取内容,并将内容存在本地电脑上,包括任何文件!利用xmlhttp和adodb.stream,酷!绝对原创!

Google
Web www.51ec.org
【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
我来说两句 对此文章发表了评论
  昵 称: *必填    ·注册用户·
  评 分: 1分 2分 3分 4分 5分     严禁发表危害国家安全、政治、黄色淫秽等内容的评论,用户需对自己在使用本网站服务过程中的行为承担法律责任。本站管理员有权保留或删除评论内容,评论内容只代表机友个人观点,与本网站立场无关。  
评 论
内 容

 
评论列表 (最新 评论仅限网友观点!)

供求信息




| 设为首页 | 加入收藏 | 关于我们 | 广告服务 | 联系方式 | 友情链接 | 版权申明