zoukankan      html  css  js  c++  java
  • 通过ASP生成html纯静态页面的简单示例

    本站收录这篇文章通过ASP生成html纯静态页面的简单示例,详细解说文章中相关静态 asp 技术与知识,欢迎能给大家一些在这方面的支持和帮助!下面是详细内容:

    原理:通过浏览器传送变量,如

    http://127.0.0.1/shengcheng.asp?id=90

    代码:
    if SaveFile("/new/"&id&".html","http://127.0.0.1/news.asp?id="&id&"") then 中

    /new"&id&".html",是你生成的文件和路径。http://127.0.0.1/news.asp?id="&id&""是asp的路径
    大家可以自己设置修改,其中 "&id&" 是读取浏览器的变量。网址改成你自己的。

    使用方法,给你的文章列表添加一个连接,如 http://127.0.0.1/shengcheng.asp?id=90

    90这个变量相信大家会调用吧,这样就能在/new目录下生成按照id排列的html文章了

    shengcheng.asp文件如下:

      程序代码(For Alixixi.com)如下:
     
      1. <%   
      2.  
      3. Dim id   
      4.  
      5. id = Request("id")   
      6.  
      7. %>   
      8.  
      9. <%   
      10.  
      11. if SaveFile("/new/"&id&".html","http://127.0.0.1/news.asp?id="&id&"") then   
      12.  
      13. Response.write "已生成"   
      14.  
      15. else   
      16.  
      17. Response.write "没有生成"   
      18.  
      19. end if  
      20.  
      21. function SaveFile(LocalFileName,RemoteFileUrl)   
      22.  
      23. Dim Ads, Retrieval, GetRemoteData   
      24.  
      25. On Error Resume Next   
      26.  
      27. Set Retrieval = Server.CreateObject("Microso" & "ft.XM" & "LHTTP") '//把单词拆开防止杀毒软件误杀  
      28.  
      29. With Retrieval   
      30.  
      31. .Open "Get", RemoteFileUrl, False, "", ""   
      32.  
      33. .Send   
      34.  
      35. GetRemoteData = .ResponseBody   
      36.  
      37. End With   
      38.  
      39. Set Retrieval = Nothing   
      40.  
      41. Set Ads = Server.CreateObject("Ado" & "db.Str" & "eam") '//把单词拆开防止杀毒软件误杀  
      42.  
      43. With Ads   
      44.  
      45. .Type = 1   
      46.  
      47. .Open   
      48.  
      49. .Write GetRemoteData   
      50.  
      51. .SaveToFile Server.MapPath(LocalFileName), 2   
      52.  
      53. .Cancel()   
      54.  
      55. .Close()   
      56.  
      57. End With   
      58.  
      59. Set Ads=nothing   
      60.  
      61. if err <> 0 then   
      62.  
      63. SaveFile = false   
      64.  
      65. err.clear   
      66.  
      67. else   
      68.  
      69. SaveFile = true   
      70.  
      71. end if   
      72.  
      73. End function   
      74.  
      75. %> 
  • 相关阅读:
    插入排序的算法分析
    SQL的UNION操作
    二分查找的思路
    怎么看吉他简谱
    一句CSS代码杜绝网站iframe挂马
    关于NewFolder.文件夹无法删除的办法
    C#监听USB接入
    C# 系统服务添加安装
    .NET 实现ISAPI过滤器,指定类型文件防下载
    ASP 简单的异或加密方法
  • 原文地址:https://www.cnblogs.com/ince/p/10424907.html
Copyright © 2011-2022 走看看