企業(yè)與個(gè)人網(wǎng)絡(luò)營銷一站式服務(wù)商
        網(wǎng)站建設(shè) / SEO優(yōu)化排名 / 小程序開發(fā) / OA
        0731-88571521
        136-3748-2004
        asp定時(shí)生成靜態(tài)HTML的代碼
        信息來源:斌網(wǎng)網(wǎng)絡(luò)   發(fā)布時(shí)間:2010-6-15   瀏覽:
        復(fù)制代碼 代碼如下:
        <% 
        ’判斷是否要生成新的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 ’比較上次更新時(shí)間與當(dāng)前時(shí)間相差多少秒 
        Application.Lock 
        Application("cache_asptohtml_date")=now() 
        Application.UnLock 
        Call aspTohtml 
        Response.Redirect("index.html") 
        Else 
        Response.Redirect("index.html") 
        End if 

        ’獲取當(dāng)前目錄! 
        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生成靜態(tài)首頁的代碼 
        ’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定時(shí)生成靜態(tài)頁(HTML)2 
        復(fù)制代碼 代碼如下:
        <% 
        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 /><!--有沒有發(fā)現(xiàn)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 ’//上次更新到現(xiàn)在的時(shí)間 大于 3600秒 則 更新 
        response.write "<br /><!--時(shí)間過了開始更新-->" 

        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 /><!-- 已經(jīng)過去"&datediff("s",times,NOW())&"秒!-->" 

        End If 
        %> 

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


        上一條: 做網(wǎng)站設(shè)計(jì)師的福音:國內(nèi)20個(gè)設(shè)計(jì)素材好網(wǎng)站
        下一條: 服務(wù)器添加隱藏賬號和檢查刪除隱藏賬號的方法
        案例鑒賞
        多年的網(wǎng)站建設(shè)經(jīng)驗(yàn),斌網(wǎng)網(wǎng)絡(luò)不斷提升技術(shù)設(shè)計(jì)服務(wù)水平,迎合搜索引擎優(yōu)化規(guī)則
        法律法規(guī)
        多年的網(wǎng)站建設(shè)經(jīng)驗(yàn),網(wǎng)至普不斷提升技術(shù)設(shè)計(jì)服務(wù)水平,迎合搜索引擎優(yōu)化規(guī)則
        長沙私人做網(wǎng)站    長沙做網(wǎng)站    深圳網(wǎng)站建設(shè)    株洲做網(wǎng)站    東莞做網(wǎng)站    南京防腐木    湖南大拇指養(yǎng)豬設(shè)備    株洲做網(wǎng)站    
        版權(quán)所有 © 長沙市天心區(qū)斌網(wǎng)網(wǎng)絡(luò)技術(shù)服務(wù)部    湘公網(wǎng)安備 43010302000270號  統(tǒng)一社會信用代碼:92430103MA4LAMB24R  網(wǎng)站ICP備案號:湘ICP備13006070號-2  
        无码精品人妻一区二区三区免费看| 久久久久久久久久久久中文字幕| 日韩精品久久无码人妻中文字幕| 欧美巨大xxxx做受中文字幕| 欧美精品中文字幕亚洲专区| 人妻无码中文字幕免费视频蜜桃| 高清无码视频直接看| 精品久久久久久无码人妻热| 岛国av无码免费无禁网| 久久无码人妻精品一区二区三区| 亚洲性无码一区二区三区| 亚洲AV永久无码精品成人| 亚洲日韩乱码中文无码蜜桃臀网站| 精品无码专区亚洲| 天堂√在线中文最新版| 无码超乳爆乳中文字幕久久| 亚洲AV蜜桃永久无码精品| 国产在线无码一区二区三区视频| 亚洲欧美在线一区中文字幕| 超清中文乱码字幕在线观看| 免费一区二区无码视频在线播放| 中文字幕丰满伦子无码| 日韩国产中文字幕| 无码任你躁久久久久久老妇| 超清无码无卡中文字幕| 精品欧洲av无码一区二区14| 无码欧精品亚洲日韩一区夜夜嗨| 无码人妻品一区二区三区精99| 亚洲成?v人片天堂网无码| 国产AV无码专区亚洲AV漫画| 在线中文字幕一区| 最近中文字幕2019高清免费| 人禽无码视频在线观看| 亚洲&#228;v永久无码精品天堂久久| 久久中文字幕人妻熟av女| 日本免费中文视频| 亚洲成av人片不卡无码久久| 日韩AV无码久久一区二区| 亚洲欧美日韩国产中文| 中文字幕无码播放免费| 人妻精品久久无码区|