上万部爽片,立即观看,在线观看,日韩av无码久久精品免费,欧美性受xxxx喷潮,欧洲男同gay,日韩精品一区二区三区

十年專(zhuān)注于品牌網(wǎng)站建設(shè) 十余年專(zhuān)注于網(wǎng)站建設(shè)_小程序開(kāi)發(fā)_APP開(kāi)發(fā),低調(diào)、敢創(chuàng)新、有情懷!
南昌百恒網(wǎng)絡(luò)微信公眾號(hào) 掃一掃關(guān)注
小程序
tel-icon全國(guó)服務(wù)熱線:400-680-9298,0791-88117053
掃一掃關(guān)注百恒網(wǎng)絡(luò)微信公眾號(hào)
掃一掃打開(kāi)百恒網(wǎng)絡(luò)微信小程序

百恒網(wǎng)絡(luò)

南昌百恒網(wǎng)絡(luò)

實(shí)現(xiàn)ASP生成HTML靜態(tài)頁(yè)面及分頁(yè)方法

百恒網(wǎng)絡(luò) 2011-12-16 6032

相關(guān)變量參數(shù): strDir 用于保存.html文件的文件夾路徑 htmlwrite FSO對(duì)象,用于生成.html文件 arrcontent 按分頁(yè)標(biāo)簽分割的文章內(nèi)容數(shù)組 InnerPageNum 統(tǒng)計(jì)內(nèi)容的頁(yè)數(shù) rollnum 當(dāng)前第(rollnum+1)頁(yè) pagelist 分頁(yè)頁(yè)碼 strTemplate 存放模板內(nèi)容 strTe

1、相關(guān)變量參數(shù):

strDir 用于保存.html文件的文件夾路徑

htmlwrite FSO對(duì)象,用于生成.html文件

arrcontent 按分頁(yè)標(biāo)簽分割的文章內(nèi)容數(shù)組

InnerPageNum 統(tǒng)計(jì)內(nèi)容的頁(yè)數(shù)

rollnum 當(dāng)前第(rollnum+1)頁(yè)

pagelist 分頁(yè)頁(yè)碼

strTemplate 存放模板內(nèi)容

strTemp 模板內(nèi)容備份

$page_break$ 內(nèi)容分頁(yè)標(biāo)簽

2、核心代碼

'========生成內(nèi)容靜態(tài)頁(yè)======

on Error resume next

Set fso = Server.CreateObject("Scripting.FileSystemObject")

'=====用于保存靜態(tài)文件的文件夾路徑名稱(chēng),這里我按自己的項(xiàng)目設(shè)定了====

strDir=SITEROOT&"/"&NewsHtmlFile&"/"&year(now)&"-"&month(now)

'======生成靜態(tài)文件保存文件夾=====

if not fso.folderexists(Server.MapPath(strDir)) then fso.CreateFolder(Server.MapPath(strDir))

set fso=Nothing

if Err=0 then

Dim fso,htmlwrite ,arrcontent,InnerPageNum,rollnum,pagelist,strTemplate,strTemp

'===讀取模板文件,我前面的文章關(guān)于ASP生成靜態(tài)的,有這個(gè)數(shù)據(jù)表的內(nèi)容===

sql="SELECT tp_content FROM [KrTemplate] WHERE tp_default=1 AND tp_type='新聞內(nèi)容頁(yè)模板'"

Set rs=Conn.Execute(sql)

if not rs.eof then

strTemplate=rs(0)

end if

rs.close

'======備份模板文件,避免模板文件被改寫(xiě)=====

strTemp=strTemplate

'======文章數(shù)據(jù)表=====

sql="SELECT * FROM [KrNews] WHERE news_html=0 ORDER BY news_date DESC"

Set rs=Conn.Execute(sql)

'======循環(huán)讀取所有要生成的文章信息======

do while not rs.eof

news_keywords=rs("news_keywords")

news_content=rs("news_content")

news_tips=rs("news_tips")

news_name=rs("news_name")

news_from=rs("news_from")

news_date=rs("news_date")

news_id=rs("news_id")

'====匹配文章內(nèi)容,如果出現(xiàn)分頁(yè)標(biāo)簽,則按如下處理,否則按普通生成方法處理===

if Instr(news_content,"$page_break$") then

'===如果文章URL要存入數(shù)據(jù)庫(kù),那么這里存入的地址就為文章分頁(yè)后的第一頁(yè)的路徑,

'===即為下面的URL地址加上第一頁(yè)的標(biāo)志,我這里存入數(shù)據(jù)庫(kù)的地址是這樣的

' ===URL=URL&"_1.html"

URL=SITEURL&strDir&"/news_"&news_id&""

'======對(duì)分頁(yè)信息的預(yù)處理=======

'=====將按分頁(yè)標(biāo)簽分割的文章內(nèi)容存入數(shù)組arrcontent=====

arrcontent=split(news_content,"$page_break$")

'=====得到文章分割后所得的頁(yè)數(shù)=====

InnerPageNum=ubound(arrcontent)

pagelist=" "

'=====循環(huán)得到頁(yè)碼======

for rollnum=0 to InnerPageNum

pagelist=pagelist & "["&(rollnum+1)&"] "

next

for rollnum=0 to InnerPageNum

'======還原被改寫(xiě)的模板,這里不注意會(huì)生成相同的文件======

strTemplate=strTemp

strTemplate=Replace(strTemplate,"$keywords$",news_keywords)

strTemplate=Replace(strTemplate,"$news_tips$",news_tips)

………… '略,其他一樣寫(xiě)法

'===替換文章內(nèi)容,并添加分頁(yè)頁(yè)碼====

strTemplate=Replace(strTemplate,"$news_content$",arrcontent(rollnum)&"

分頁(yè):"&pagelist&"

")

'====要生成的HTML頁(yè)面路徑及名稱(chēng)======

Address=strDir&"/news_"&news_id&"_"&(rollnum+1)&".html"

'======調(diào)用adodb.stream方法生成靜態(tài)頁(yè)面,此為自定義方法,附在文章后面===

WriteToTextFile Address,strTemplate

'======(可選擇)FSO方法生成靜態(tài)頁(yè)面

' Set fso = Server.CreateObject("Scripting.FileSystemObject")

' Set htmlwrite=fso.CreateTextFile(Server.MapPath(Address),true) '// 創(chuàng)建要生成的靜態(tài)頁(yè)

' htmlwrite.WriteLine strTemplate '// 寫(xiě)入網(wǎng)頁(yè)內(nèi)容

' htmlwrite.close

' set htmlwrite=Nothing

' set fso=Nothing

next

else

strTemplate=Replace(strTemplate,"$keywords$",news_keywords)

strTemplate=Replace(strTemplate,"$news_tips$",news_tips)

strTemplate=Replace(strTemplate,"$sitename$",SITENAME)

…………

strTemplate=Replace(strTemplate,"$news_content$",news_content)

Address=strDir&"/news_"&rs("news_id")&".html"

WriteToTextFile Address,strTemplate

end if

rs.movenext

loop

rs.close

end if

'=======ADODB.Stream生成文件函數(shù)=========

Sub WriteToTextFile (FileUrl,byval Str)

set stm=server.CreateObject("adodb.stream")

stm.Type=2 '以本模式讀取

stm.mode=3

stm.charset="GB2312"

stm.open

stm.WriteText str

stm.SaveToFile server.MapPath(FileUrl),2

stm.flush

stm.Close

str=""

set stm=nothing

End Sub


400-680-9298,0791-88117053
掃一掃關(guān)注百恒網(wǎng)絡(luò)微信公眾號(hào)
掃一掃打開(kāi)百恒網(wǎng)絡(luò)小程序

歡迎您的光顧,我們將竭誠(chéng)為您服務(wù)×

售前咨詢 售前咨詢
 
售前咨詢 售前咨詢
 
售前咨詢 售前咨詢
 
售前咨詢 售前咨詢
 
售前咨詢 售前咨詢
 
售后服務(wù) 售后服務(wù)
 
售后服務(wù) 售后服務(wù)
 
備案專(zhuān)線 備案專(zhuān)線
 
×