• 24小时服务热线:
  • 0838-6611186


☞ 您的位置:首页 › > 代码技巧

PJ3博客系统生成静态首页的简单方法
          发布日期:2019-7-27 14:21:41 人气: 标签:静态

下面的代码存成一个asp页面然后访问一次即可!
注意IIS里的文档要调为index.htm优先才可以,在官方的正式静态没出来前这是个不错的临时解决办法,比之前的直接访问动态页面要爽多了,不用再死等服务器的处理了! (此代码也适合其它首页非静态的处理)
< %
dim strUrl,Item_Classid,id,FileName,FilePath,Do_Url,Html_Temp
Html_Temp="

    "
    For i=1 To 1
    Html_Temp = Html_Temp&"
  • "
    Item_Classid = i
    FileName = "index.htm"
    FilePath = Server.MapPath("/")&"\"&FileName
    Html_Temp = Html_Temp&FilePath&""
    Do_Url = "http://"
    Do_Url = Do_Url&Request.ServerVariables("SERVER_NAME")&"/default.asp"
    'Do_Url = Do_Url&"?Item_Classid="&Item_Classid
    strUrl = Do_Url
    call makehtml (strUrl,FilePath)
    Next
    Html_Temp = Html_Temp&"
      "
      Response.Write ( "首页发布完成!" )
      Response.Write ( "
      " )
      Response.Write Html_Temp

       

      function makehtml(strUrl,FilePath)
      dim objXmlHttp
      set objXmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
      objXmlHttp.open "GET",strUrl,false
      objXmlHttp.send()
      Dim binFileData
      binFileData = objXmlHttp.responseBody
      Dim objAdoStream
      set objAdoStream = Server.CreateObject("ADODB.Stream")
      objAdoStream.Type = 1
      objAdoStream.Open()
      objAdoStream.Write(binFileData)
      objAdoStream.SaveToFile FilePath,2
      objAdoStream.Close()
      end function
      % >