日期:2009-12-18  浏览次数:20866 次

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

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文件如下:

  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&n