网站推广-网站优化-合肥久飞SEO论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 7462|回复: 0

asp网站制作教程之ASP静态化生成html方法

[复制链接]
发表于 2014-3-2 14:16:38 | 显示全部楼层 |阅读模式
  1. <%
  2. '当目标页面的包含文件即#include的页面里边存在response.End()的时候本程序有问题
  3. '注意:本文件一定要放在20041227111723.htm指向的文件的同一目录下
  4. dim hughchiu_rtcode
  5. Function get_exe_code(20041227111723.htm)
  6. dim execode
  7. dim tmp_str
  8. Dim re,re1,content,fso,f,aspStart,aspEnd
  9. dim ms,m
  10. execode = ""
  11. set fso=CreateObject("Scripting.FileSystemObject")
  12. set f=fso.OpenTextFile(server.mappath(20041227111723.htm))
  13. content=f.ReadAll
  14. f.close
  15. set f=nothing
  16. set fso=nothing
  17. set re = new regexp
  18. re.ignorecase = true
  19. re.global = true
  20. re.pattern = "\<\%\@[^\%]+\%\>"
  21. content = re.replace(content,"")
  22. re.global = false
  23. re.pattern = "\<\!\-\-\s*\#include\s*file\s*=\s*""([^""]+)""\s*\-\-\>"
  24. do
  25. set ms = re.execute(content)
  26. if ms.count<>0 then
  27. set m = ms(0)
  28. tmp_str = get_exe_code(m.submatches(0))
  29. content = re.replace(content, tmp_str)
  30. else
  31. exit do
  32. end if
  33. loop
  34. set m = nothing
  35. set ms = nothing
  36. re.pattern="^\s*="
  37. aspEnd=1
  38. aspStart=inStr(aspEnd,content,"<%")+2
  39. set re1=new RegExp
  40. re1.ignorecase = true
  41. re1.global = false
  42. re1.pattern = "response\.Write(.+)"
  43. do while aspStart>aspEnd+1
  44. execode = execode&vbcrlf&" hughchiu_rtcode = hughchiu_rtcode&"""&replace( replace(Mid(content,aspEnd,aspStart-aspEnd-2),"""",""""""), vbcrlf, """&vbcrlf&""")&""""&vbcrlf
  45. aspEnd=inStr(aspStart,content,"%\>")+2
  46. tmp_str = Mid(content,aspStart,aspEnd-aspStart-2)
  47. do
  48. set ms = re1.execute(tmp_str)
  49. if ms.count<>0 then
  50. set m = ms(0)
  51. tmp_str = re1.replace(tmp_str, " hughchiu_rtcode = hughchiu_rtcode&"&m.submatches(0))
  52. else
  53. exit do
  54. end if
  55. loop
  56. set m = nothing
  57. set ms = nothing
  58. execode = execode& re.replace(tmp_str,"hughchiu_rtcode = hughchiu_rtcode&")
  59. aspStart=inStr(aspEnd,content,"<%")+2
  60. loop
  61. set re1 = nothing
  62. set re=nothing
  63. execode = execode&vbcrlf&" hughchiu_rtcode = hughchiu_rtcode&"""&replace( replace(Mid(content,aspEnd), """", """"""), vbcrlf, """&vbcrlf&""" )&""""&vbcrlf
  64. get_exe_code = "<%"&execode&"%\>"
  65. End Function
  66. function asp2html(20041227111723.htm)
  67. dim code
  68. code = replace( replace( replace( get_exe_code(20041227111723.htm), "hughchiu_rtcode = hughchiu_rtcode&"""""&vbcrlf, "" ), "<%", "" ), "%\>", "" )
  69. 'response.Write(code)
  70. execute(code)
  71. 'response.Write( hughchiu_rtcode )
  72. asp2html = hughchiu_rtcode
  73. end function
  74. %>
复制代码


本文地址: https://jiufei.net/bbs/thread-11252-1-1.html
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|合肥网站优化,合肥百度优化,合肥网络推广,合肥SEO优化论坛 ( 皖ICP备2022014487号-2 )

GMT+8, 2025-1-31 07:35 , Processed in 0.067145 second(s), 15 queries , File On.

Powered by jiufei X3.4

© 2008-2020 www.jiufei.net

快速回复 返回顶部 返回列表