激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

香港云服务器
服務(wù)器之家 - 編程語言 - ASP教程 - asp定時生成靜態(tài)HTML的代碼

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

2019-09-03 11:23服務(wù)器之家 ASP教程

asp定時生成靜態(tài)HTML的代碼,對于緩解服務(wù)器壓力有很大幫主,需要的朋友可以參考下。

代碼如下:

<% 
'判斷是否要生成新的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生成靜態(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定時生成靜態(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)在的時間 大于 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 /><!-- 已經(jīng)過去"&datediff("s",times,NOW())&"秒!-->" 

End If 
%> 

延伸 · 閱讀

精彩推薦
301
主站蜘蛛池模板: 久久99综合久久爱伊人 | 精品一区二区三区毛片 | 国产99久久精品一区二区 | 国产超碰人人做人人爱ⅴa 色天天综合网 | 精品一区二区三区在线视频 | 日韩精品中文字幕一区二区 | 成人av一二三区 | 羞羞视频免费视频欧美 | 黄色视屏免费在线观看 | 羞羞答答影院 | 国产精品久久久久久久久久久久久久久 | 欧美一级高清免费 | 美女啪网站 | 黄色免费在线电影 | 久啪视频| 中文字幕免费在线看 | 欧美性精品videofree | www.三区| 久久国产成人精品国产成人亚洲 | asiass极品裸体女pics | 日韩一级免费毛片 | 91高清免费 | 欧美精品一区二区视频 | 精品国产一区二区三区四区在线 | 国产一区二区三区视频观看 | 中国hdxxxx护士爽在线观看 | av免费入口 | 狠狠色噜噜狠狠狠米奇9999 | 草莓福利社区在线 | 久久色伦理资源站 | 99热99精品| japan护士性xxxⅹhd | 日本中文一级片 | 久久狠狠高潮亚洲精品 | 国产午夜三级一区二区三桃花影视 | 亚洲精品自在在线观看 | 最新日本中文字幕在线观看 | 欧美人成在线 | 毛片118极品美女写真 | 青青草成人自拍 | 久久91亚洲人成电影网站 |