分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

通过ASP生成html纯静态页面的简单示例

发布时间:2023-09-06 02:33责任编辑:苏小强关键词:暂无标签

本站收录这篇文章通过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. %> 

通过ASP生成html纯静态页面的简单示例

原文地址:https://www.cnblogs.com/ince/p/10424907.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved