濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > asp定時(shí)生成靜態(tài)HTML的代碼

asp定時(shí)生成靜態(tài)HTML的代碼

熱門(mén)標(biāo)簽:地圖標(biāo)注服務(wù)哪家好 地圖標(biāo)注宅基地 武漢營(yíng)銷電話機(jī)器人軟件 騰訊地圖標(biāo)注商戶關(guān)閉 西寧公司外呼系統(tǒng)平臺(tái) 外呼系統(tǒng)還用卡么 長(zhǎng)沙防封電銷卡品牌 徐州人工智能電銷機(jī)器人好用嗎 智能電銷機(jī)器人適用于哪些行業(yè)

復(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)首頁(yè)的代碼
'Curl 為你的首頁(yè)地址,確保你的空間支持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)頁(yè)(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 />!--有沒(méi)有發(fā)現(xiàn)time.txt 開(kāi)始生成!-->"
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í)間過(guò)了開(kāi)始更新-->"

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

'//用FSO生成HTML頁(yè)面
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)過(guò)去"datediff("s",times,NOW())"秒!-->"

End If
%>

您可能感興趣的文章:
  • PHP實(shí)現(xiàn)定時(shí)生成HTML網(wǎng)站首頁(yè)實(shí)例代碼

標(biāo)簽:鷹潭 巴彥淖爾 通化 運(yùn)城 荊門(mén) 雅安 通遼 普洱

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp定時(shí)生成靜態(tài)HTML的代碼》,本文關(guān)鍵詞  asp,定時(shí),生成,靜態(tài),HTML,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp定時(shí)生成靜態(tài)HTML的代碼》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于asp定時(shí)生成靜態(tài)HTML的代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    盱眙县| 茶陵县| 出国| 沙河市| 葫芦岛市| 中山市| 武川县| 桦南县| 张家港市| 林西县| 盐城市| 金沙县| 昌宁县| 桐梓县| 河西区| 江孜县| 峡江县| 吕梁市| 河池市| 沽源县| 沾化县| 邻水| 永兴县| 浦东新区| 普陀区| 舞阳县| 阿坝县| 甘孜县| 龙南县| 双牌县| 宁德市| 厦门市| 罗源县| 霍林郭勒市| 安图县| 昭苏县| 凭祥市| 红桥区| 安达市| 崇仁县| 永顺县|