2010-06
25

修改PJblog中SiteMap.asp自动生成SiteMap.xml的方法


      在PJBLOG3中默认SiteMap.asp生成SiteMap.xml只有11条网页数据,因此当你把该SiteMap.xml提交到GOOGLE时,“以提交的网址”也只能显示11。这个不利于GOOGLE全部抓取我们的网站,所以在此告诉大家两个比较简单的方法:

一、把SiteMap.asp修改为如下内容(其中的SiteURL=””改为自己的网址)

<!–#include file=”const.asp” –>
<!–#include file=”conn.asp” –>
<!–#include file=”common/cache.asp” –>
<!–#include file=”common/function.asp” –>
<!–r /> dim mydata,ID,url,myxml,mydaya,elem,mytime,iPrior,data1,rs,i
SiteURL=”http://www.sangsan.cn/
mydata=ISO8601(DateAdd(“h”,-1,Now))
Response.ContentType=”text/xml”
Response.Charset=”UTF-8″
myxml=”"&#038;VbCrLf
myxml=myxml&#038;”<urlset xmlns=”"http://www.google.com/schemas/sitemap/0.84″”>”&#038;VbCrLf
myxml=myxml&#038;”<url>”&#038;VbCrLf
myxml=myxml&#038;”<loc>”&#038;SiteURL&#038;”</loc>”&#038;VbCrLf
myxml=myxml&#038;”<lastmod>”&#038;mydata&#038;”</lastmod>”&#038;VbCrLf
myxml=myxml&#038;”<changefreq>always</changefreq>”&#038;VbCrLf
myxml=myxml&#038;”
<priority>0.9</priority>”&#038;VbCrLf
myxml=myxml&#038;”</url>”&#038;VbCrLf
SQL=”Select * FROM blog_Content”
Set rs=Server.CreateObject(“ADODB.Recordset”)
rs.Open SQL,Conn,1,1
rs.movelast
for i=1 to rs.recordcount
ID=rs(“log_ID”)
elem=elem&#038;”<url>”&#038;VbCrLf
elem=elem&#038;”<loc>”
url=SiteURL&#038;”article.asp?id=”&#038;ID
elem=elem&#038;url
elem=elem&#038;”</loc>”&#038;VbCrLf
mytime=rs(“log_PostTime”)
elem=elem&#038;”<lastmod>”&#038;ISO8601(mytime)&#038;”</lastmod>”&#038;VbCrLf
elem=elem&#038;”<changefreq>”
If DateDiff(“h”, mytime, Now) < 24 Then
data1=”hourly”
iPrior=”0.8″
ElseIf DateDiff(“d”, mytime, Now) < 7 Then
data1= “daily”
iPrior=”0.7″
ElseIf DateDiff(“ww”, mytime, Now) < 4 Then
data1=”weekly”
ElseIf DateDiff(“m”, mytime, Now) < 12 Then
data1= “monthly”
Else
data1= “yearly”
End If
elem=elem&#038;data1
elem=elem&#038;”</changefreq>”&#038;VbCrLf
elem=elem&#038;”
<priority>”
elem=elem&#038;iPrior
elem=elem&#038;”</priority>”&#038;VbCrLf
elem=elem&#038; “</url>”&#038;VbCrLf
rs.moveprevious
next
elem=elem&#038; “</urlset>”
myxml=myxml&#038;elem
response.write myxml
RS.close : Set RS=nothing
Conn.Close
Set Conn=Nothing
Function ISO8601(DateTime)
Dim DateMonth,DateDay,DateHour,DateMinute,DateWeek,DateSecond
DateTime = DateAdd(“h”,-8,DateTime)
DateMonth=Month(DateTime)
DateDay=Day(DateTime)
DateHour=Hour(DateTime)
DateMinute=Minute(DateTime)
DateWeek=weekday(DateTime)
DateSecond=Second(DateTime)
If Len(DateMonth)<2 Then DateMonth=”0″&#038;DateMonth
If Len(DateDay)<2 Then DateDay=”0″&#038;DateDay
If Len(DateMinute)<2 Then DateMinute=”0″&#038;DateMinute
If Len(DateHour)<2 Then DateHour=”0″&#038;DateHour
If Len(DateSecond)<2 Then DateSecond=”0″&#038;DateSecond
ISO8601=Year(DateTime)&#038;”-”&#038;DateMonth&#038;”-”&#038;DateDay&#038;”T”&#038;DateHour&#038;”:”&#038;DateMinute&#038;”:”&#038;DateSecond&#038;”Z”
End Function
dim xmlfile,fso,myfile
xmlfile=server.mappath(“sitemap.xml”)
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set MyFile = fso.CreateTextFile(xmlfile,True)
MyFile.WriteLine myxml
MyFile.close
–>


二、把SiteMap.asp中如下内容的10改成你想要的数字(默认只搜索最新的10篇日志,一共有两处):
SQL = "Select top 10


修改好SiteMap.asp后上传到网站覆盖原来文文件,再访问如http://www.sangsan.cn/SiteMap.asp即可。



上一篇: 《咏 荷》——田园
下一篇: 周杰伦2010“超时代”演唱会完整版
文章来自: 桑三博客
引用通告: 查看所有引用 | 我要引用此文章
Tags: Pjblog 网页代码
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 关闭