企業與個人網絡營銷一站式服務商
        網站建設 / SEO優化排名 / 小程序開發 / OA
        0731-88571521
        136-3748-2004
        asp定時生成靜態HTML的代碼
        信息來源:斌網網絡   發布時間:2010-6-15   瀏覽:
        復制代碼 代碼如下:
        <% 
        ’判斷是否要生成新的HTML 
        if Application("cache_asptohtml_date")="" then 
        Application.Lock 
        Application("cache_asptohtml_date")=now() 
        Application.Unlock 
        Call aspTohtml 
        Response.Redirect("index.html") 
        end if 
        if DateDiff("s", Application("cache_asptohtml_date"),Now)> 100 then ’比較上次更新時間與當前時間相差多少秒 
        Application.Lock 
        Application("cache_asptohtml_date")=now() 
        Application.UnLock 
        Call aspTohtml 
        Response.Redirect("index.html") 
        Else 
        Response.Redirect("index.html") 
        End if 

        ’獲取當前目錄! 
        function getpath 
        if Request.ServerVariables("SERVER_PORT")<>"80" then 
        UserUrl = "http://"&Request.ServerVariables("SERVER_NAME")& ":" & Request.ServerVariables("SERVER_PORT")& Request.ServerVariables("URL") 
        else 
        UserUrl = "http://"&Request.ServerVariables("SERVER_NAME")& Request.ServerVariables("URL") 
        end if 
        getpath=left(UserUrl,InstrRev(UserUrl,"/")) 
        end function 

        sub aspTohtml 
        ’---------------------------------------------------------- 
        ’使用XMLHTTP生成靜態首頁的代碼 
        ’Curl 為你的首頁地址,確保你的空間支持FSO 
        ’----------------------------------------------------------- 
        dim read,Curl,content 
        Curl=getpath&"home.asp" 
        read=getHTTPPage(Curl) 
        if read<>"" then 
        content=read 
        Set Fso = Server.CreateObject("Scripting.FileSystemObject") 
        Filen=Server.MapPath("index.html") 
        Set Site_Config=FSO.CreateTextFile(Filen,true, False) 
        Site_Config.Write content 
        Site_Config.Close 
        Set Fso = Nothing 
        end if 
        End sub 
        Function getHTTPPage(url) 
        dim http 
        set http=Server.createobject("Microsoft.XMLHTTP") 
        Http.open "GET",url,false 
        Http.send() 
        if Http.readystate<>4 then 
        exit function 
        end if 
        getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312") 
        set http=nothing 
        if err.number<>0 then err.Clear 
        End Function 

        Function BytesToBstr(body,Cset) 
        dim objstream 
        set objstream = Server.CreateObject("adodb.stream") 
        objstream.Type = 1 
        objstream.Mode =3 
        objstream.Open 
        objstream.Write body 
        objstream.Position = 0 
        objstream.Type = 2 
        objstream.Charset = Cset 
        BytesToBstr = objstream.ReadText 
        objstream.Close 
        set objstream = nothing 
        End Function 
        %> 

        ASP定時生成靜態頁(HTML)2 
        復制代碼 代碼如下:
        <% 
        set fs=server.createobject("scripting.filesystemobject") 
        file=server.mappath("time.txt") 
        set txt=fs.opentextfile(file,1,true) 
        if not txt.atendofstream then 
        times=txt.ReadLine 
        Else 
        response.write "<br /><!--有沒有發現time.txt 開始生成!-->" 
        HtmlPage = "time.txt" ’//生成的HTML文件名 
        Template = NOW() 
        Set FSO = Server.CreateObject ("Scripting.FileSystemObject") 
        Set FileOut = FSO.CreateTextFile(Server.MapPath (HtmlPage)) 
        FileOut.WriteLine Template 
        FileOut.Close 
        Set FSO = Nothing 
        end If 


        If datediff("s",times,NOW()) > 3600 Then ’//上次更新到現在的時間 大于 3600秒 則 更新 
        response.write "<br /><!--時間過了開始更新-->" 

        code = "這里是需要生成的html代碼" ’//如何得到代碼的方式有很多 

        ’//用FSO生成HTML頁面 
        HtmlPage = "index.html" ’//生成的HTML文件名 
        Template = code 
        Set FSO = Server.CreateObject ("Scripting.FileSystemObject") 
        Set FileOut = FSO.CreateTextFile(Server.MapPath (HtmlPage)) 
        FileOut.WriteLine Template 
        FileOut.Close 
        Set FSO = Nothing 

        ’//用FSO生成time.txt文件 
        HtmlPage = "time.txt" ’//生成的HTML文件名 
        Template = NOW() 
        Set FSO = Server.CreateObject ("Scripting.FileSystemObject") 
        Set FileOut = FSO.CreateTextFile(Server.MapPath (HtmlPage)) 
        FileOut.WriteLine Template 
        FileOut.Close 
        Set FSO = Nothing 

        Else 

        response.write "<br /><!-- 已經過去"&datediff("s",times,NOW())&"秒!-->" 

        End If 
        %> 

        詳細出處參考:http://www.jb51.net/article/23955.htm


        上一條: 做網站設計師的福音:國內20個設計素材好網站
        下一條: 服務器添加隱藏賬號和檢查刪除隱藏賬號的方法
        案例鑒賞
        多年的網站建設經驗,斌網網絡不斷提升技術設計服務水平,迎合搜索引擎優化規則
        法律法規
        多年的網站建設經驗,網至普不斷提升技術設計服務水平,迎合搜索引擎優化規則
        長沙私人做網站    長沙做網站    深圳網站建設    株洲做網站    東莞做網站    湖南大拇指養豬設備    株洲做網站    
        版權所有 © 長沙市天心區斌網網絡技術服務部    湘公網安備 43010302000270號  統一社會信用代碼:92430103MA4LAMB24R  網站ICP備案號:湘ICP備13006070號-2  
        中文字幕亚洲乱码熟女一区二区 | 亚洲免费日韩无码系列 | 亚洲AV无码码潮喷在线观看| 无码专区国产无套粉嫩白浆内射 | 色欲综合久久中文字幕网| 人妻少妇乱子伦无码视频专区| 最近中文字幕2019高清免费| 国产亚洲情侣一区二区无码AV | 中文字幕在线免费| 人妻精品久久无码区| 影音先锋中文无码一区| 中文字幕无码av激情不卡久久| 国产精品亚洲аv无码播放| 最新中文字幕AV无码不卡| 中文字幕一区二区三区在线观看| 无套内射在线无码播放| 中文字幕日本高清| 精品久久久久久中文字幕| 亚洲AV无码乱码精品国产| 2019亚洲午夜无码天堂| 日韩精品久久无码中文字幕| 亚洲国产精品无码久久一区二区| 亚洲欧美成人久久综合中文网| 人妻AV中文字幕一区二区三区| 中文字幕亚洲欧美日韩2019| 特级小箩利无码毛片| 日韩欧国产精品一区综合无码| 人妻无码中文久久久久专区| 无码人妻精品一区二区三区99仓本| 无码粉嫩小泬无套在线观看| 中文字幕人成乱码在线观看| 中文字幕精品无码久久久久久3D日动漫| 最近中文字幕完整在线看一| 日韩欧美成人免费中文字幕| 在线观看中文字幕| 久久亚洲2019中文字幕| 中文字幕毛片| 无码人妻精品一区二区三区夜夜嗨| 无码精品人妻一区二区三区漫画| 免费看又黄又无码的网站| 波多野结AV衣东京热无码专区|