熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

能夠生成googlexml地圖的asp源碼

2022-06-13   來源: .NET編程 
<!#include file=connasp>
<%
session(count)=
strURL = // & requestservervariables(SERVER_NAME) & _
left(requestservervariables(SCRIPex)len(requestservervariables(SCRIPex))len(/sitemapasp))
dim foolcat
foolcat = foolcat + <?xml version= encoding=UTF?>
foolcat = foolcat + <!Google Site Map File Generated by & return_RFC_Date(nowGMT) & >
foolcat = foolcat + <urlset xmlns=>
foolcat = foolcat + <url>
foolcat = foolcat + <loc> & strURL & /</loc>
foolcat = foolcat + </url>
session(count)=session(count)+
set all_fs = ServerCreateObject(ScriptingFileSystemObject)
set all_folder = all_fsGetFolder(serverMapPath(/))
set all_files = all_folderfiles
for each file in all_files
foolcat = foolcat + <url>
foolcat = foolcat + <loc> & strURL & / & FileName & </loc>
foolcat = foolcat + </url>
session(count)=session(count)+
next
dim jssql
set js = serverCreateObject(ADODBRecordSet)
sql = select * from [要生成的表名] order by sid asc    修改你要生成的數據表名
set js = connexecute (sql)
do until jseof
id=&js(id)&   修改為你的id字段
foolcat = foolcat + <url>
foolcat = foolcat + <loc> & strURL & /xxxasp?Id= & id & </loc>   修改為你的文件名稱和id
foolcat = foolcat + </url>
session(count)=session(count)+
jsmovenext
loop
jsclose
set js = nothing
foolcat = foolcat + </urlset>
foolcat = + foolcat +
foolcat = & foolcat &
FolderPath = ServerMapPath(/)
Set fso = ServerCreateObject(ScriptingFileSystemObject)
Set fout = fsoCreateTextFile(FolderPath&\sitemapxml)
foutwriteLine foolcat
foutclose
set fout = nothing
connclose
set conn = nothing
Function return_RFC_Date(byVal myDate byVal TimeZone)
Dim myDay myDays myMonth myYear
Dim myHours myMinutes mySeconds
  
myDate = CDate(myDate)
myDay = EnWeekDayName(myDate)
myDays = Right( & Day(myDate))
myMonth = EnMonthName(myDate)
myYear = Year(myDate)
myHours = Right( & Hour(myDate))
myMinutes = Right( & Minute(myDate))
mySeconds = Right( & Second(myDate))
  
return_RFC_Date = myDay& & _
myDays& & _
myMonth& & _
myYear& & _
myHours&:& _
myMinutes&:& _
mySeconds& & _
& TimeZone
End Function
Function EnWeekDayName(InputDate)
Dim Result
Select Case WeekDay(InputDate)
Case :Result=Sun
Case :Result=Mon
Case :Result=Tue
Case :Result=Wed
Case :Result=Thu
Case :Result=Fri
Case :Result=Sat
End Select
EnWeekDayName = Result
End Function
Function EnMonthName(InputDate)
Dim Result
Select Case Month(InputDate)
Case :Result=Jan
Case :Result=Feb
Case :Result=Mar
Case :Result=Apr
Case :Result=May
Case :Result=Jun
Case :Result=Jul
Case :Result=Aug
Case :Result=Sep
Case :Result=Oct
Case :Result=Nov
Case :Result=Dec
End Select
EnMonthName = Result
End Function
%>
sitemapxml生成完畢共生成<%=session(count)%>個文件點擊查看<a >sitemapxml</a>文件

From:http://tw.wingwit.com/Article/program/net/201311/12231.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.