为google量身定做的sitemap生成代码asp版
网络编程 2021-07-05 10:58www.168986.cn编程入门
看过的朋友可帮忙顶哦,这些代码都是第一次发的,外面很多要不就是很复杂,看不懂,要不就是不能用的,狼蚁网站SEO优化的我写时候已经尽量简洁明了
外面很多所谓sitemap生成代码都只生成目录文件地址,没生成动态的,我后来自己写了这个,是支持动态的,例子: 如你是文章网站,文章有2000条,那你修改下对应你的文章数据表,即可生成除了所有目录文件外,还生成你的动态2000条地址,绝对的没话说,生成速度非常快
把狼蚁网站SEO优化代码保存为sitemap.asp文件,修改我已注明的几个地方,其他的一概不要修改,好不好用过才知道。
<!--#include file="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 by http://.xxx. " & return_RFC822_Date(now,"GMT") & "-->"
foolcat = foolcat + "<urlset xmlns=""http://.google./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 [要生成的表名] order by id asc" //修改你要生成的数据表名
set js = conn.execute (sql)
do until js.eof
id=""&js("id")"" //修改为你的id字段
foolcat = foolcat + "<url>"
foolcat = foolcat + "<loc>" & strURL & "/xxx.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
%>
把狼蚁网站SEO优化代码保存为sitemap.asp文件,修改我已注明的几个地方,其他的一概不要修改,好不好用过才知道。
代码如下:
<!--#include file="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 by http://.xxx. " & return_RFC822_Date(now,"GMT") & "-->"
foolcat = foolcat + "<urlset xmlns=""http://.google./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 [要生成的表名] order by id asc" //修改你要生成的数据表名
set js = conn.execute (sql)
do until js.eof
id=""&js("id")"" //修改为你的id字段
foolcat = foolcat + "<url>"
foolcat = foolcat + "<loc>" & strURL & "/xxx.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
%>
编程语言
- 如何快速学会编程 如何快速学会ug编程
- 免费学编程的app 推荐12个免费学编程的好网站
- 电脑怎么编程:电脑怎么编程网咯游戏菜单图标
- 如何写代码新手教学 如何写代码新手教学手机
- 基础编程入门教程视频 基础编程入门教程视频华
- 编程演示:编程演示浦丰投针过程
- 乐高编程加盟 乐高积木编程加盟
- 跟我学plc编程 plc编程自学入门视频教程
- ug编程成航林总 ug编程实战视频
- 孩子学编程的好处和坏处
- 初学者学编程该从哪里开始 新手学编程从哪里入
- 慢走丝编程 慢走丝编程难学吗
- 国内十强少儿编程机构 中国少儿编程机构十强有
- 成人计算机速成培训班 成人计算机速成培训班办
- 孩子学编程网上课程哪家好 儿童学编程比较好的
- 代码编程教学入门软件 代码编程教程