asp网站地图sitemap生成源码

    选择打赏方式

使用方法:直接放在网站根目录,修改conn配置文件、你要生成的数据表名、修改你的id字段 、修改你的文件名称和id

<!--#include file="inc/conn.asp"--> 
<% 
session("count")=0 
strURL = "http://" & request.servervariables("SERVER_NAME") & _ 
left(request.servervariables("SCRIPT_NAME"),len(request.servervariables("SCRIPT_NAME"))-len("/sitemap.asp")) 
dim foolcat 
foolcat = foolcat + "<?xml version=""1.0"" encoding=""UTF-8""?>"
foolcat = foolcat + "<!--Google Site Map File Generated  " & return_RFC822_Date(now,"GMT") & "-->"
foolcat = foolcat + "<urlset xmlns=""http://www.google.com/schemas/sitemap/0.84"">"
foolcat = foolcat + "<url>"
foolcat = foolcat + "<loc>" & strURL & "/</loc> "
foolcat = foolcat + "</url>"
session("count")=session("count")+"1"
set all_fs = Server.CreateObject("Scripting.FileSystemObject") 
set all_folder = all_fs.GetFolder(server.MapPath("/")) 
set all_files = all_folder.files 
for each file in all_files 
foolcat = foolcat + "<url>"
foolcat = foolcat + "<loc>" & strURL & "/" & File.Name & "</loc> "
foolcat = foolcat + "</url>"
session("count")=session("count")+"1"
next 
dim js,sql 
set js = server.CreateObject("ADODB.RecordSet") 
sql = "select * from article order by sid asc" //修改你要生成的数据表名 
set js = conn.execute (sql) 
do until js.eof 
id=""&js("id")&"" //修改为你的id字段 
foolcat = foolcat + "<url>"
foolcat = foolcat + "<loc>" & strURL & "/Article.asp?Id=" & id & "</loc> " //修改为你的文件名称和id 
foolcat = foolcat + "</url>"
session("count")=session("count")+"1"
js.movenext 
loop 
js.close 
set js = nothing 
foolcat = foolcat + "</urlset>"
foolcat = "" + foolcat + ""
foolcat = "" & foolcat & ""
FolderPath = Server.MapPath("/") 
Set fso = Server.CreateObject("Scripting.FileSystemObject") 
Set fout = fso.CreateTextFile(FolderPath&"\sitemap.xml") 
fout.writeLine foolcat 
fout.close 
set fout = nothing 
conn.close 
set conn = nothing 
Function return_RFC822_Date(byVal myDate, byVal TimeZone) 
Dim myDay, myDays, myMonth, myYear 
Dim myHours, myMinutes, mySeconds 
 
myDate = CDate(myDate) 
myDay = EnWeekDayName(myDate) 
myDays = Right("00" & Day(myDate),2) 
myMonth = EnMonthName(myDate) 
myYear = Year(myDate) 
myHours = Right("00" & Hour(myDate),2) 
myMinutes = Right("00" & Minute(myDate),2) 
mySeconds = Right("00" & Second(myDate),2) 
 
return_RFC822_Date = myDay&", "& _ 
myDays&" "& _ 
myMonth&" "& _ 
myYear&" "& _ 
myHours&":"& _ 
myMinutes&":"& _ 
mySeconds&" "& _ 
" " & TimeZone 
End Function 
Function EnWeekDayName(InputDate) 
Dim Result 
Select Case WeekDay(InputDate,1) 
Case 1:Result="Sun"
Case 2:Result="Mon"
Case 3:Result="Tue"
Case 4:Result="Wed"
Case 5:Result="Thu"
Case 6:Result="Fri"
Case 7:Result="Sat"
End Select 
EnWeekDayName = Result 
End Function 
Function EnMonthName(InputDate) 
Dim Result 
Select Case Month(InputDate) 
Case 1:Result="Jan"
Case 2:Result="Feb"
Case 3:Result="Mar"
Case 4:Result="Apr"
Case 5:Result="May"
Case 6:Result="Jun"
Case 7:Result="Jul"
Case 8:Result="Aug"
Case 9:Result="Sep"
Case 10:Result="Oct"
Case 11:Result="Nov"
Case 12:Result="Dec"
End Select 
EnMonthName = Result 
End Function 
%>
sitemap.xml生成完毕,共生成<%=session("count")%>个文件,点击查看<a href="sitemap.xml">sitemap.xml</a>文件。
版权声明:若无特殊注明,本文为《明月浩空》原创,转载请保留文章出处。
本文链接:https://blog.myhkw.cn/asp_sitemap.html
正文到此结束

热门推荐

发表吐槽

你肿么看?

你还可以输入 250 / 250 个字

嘻嘻 大笑 可怜 吃惊 害羞 调皮 鄙视 示爱 大哭 开心 偷笑 嘘 奸笑 委屈 抱抱 愤怒 思考 日了狗 胜利 不高兴 阴险 乖 酷 滑稽

评论信息框
可使用QQ号实时获取昵称+头像

私密评论

吃奶的力气提交吐槽中...

已有1条吐槽

匿名

3年前 (2021-10-06) 江西省南昌市电信
[私密评论]
签到成功!签到时间:上午9:07:42,每日打卡,生活更精彩哦~
 Android 9   MQQBrowser 6.2
匿名