2010-06
25
修改PJblog中SiteMap.asp自动生成SiteMap.xml的方法
作者:桑三 日期:2010-06-25
在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=”"&VbCrLf
myxml=myxml&”<urlset xmlns=”"http://www.google.com/schemas/sitemap/0.84″”>”&VbCrLf
myxml=myxml&”<url>”&VbCrLf
myxml=myxml&”<loc>”&SiteURL&”</loc>”&VbCrLf
myxml=myxml&”<lastmod>”&mydata&”</lastmod>”&VbCrLf
myxml=myxml&”<changefreq>always</changefreq>”&VbCrLf
myxml=myxml&”
<priority>0.9</priority>”&VbCrLf
myxml=myxml&”</url>”&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&”<url>”&VbCrLf
elem=elem&”<loc>”
url=SiteURL&”article.asp?id=”&ID
elem=elem&url
elem=elem&”</loc>”&VbCrLf
mytime=rs(“log_PostTime”)
elem=elem&”<lastmod>”&ISO8601(mytime)&”</lastmod>”&VbCrLf
elem=elem&”<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&data1
elem=elem&”</changefreq>”&VbCrLf
elem=elem&”
<priority>”
elem=elem&iPrior
elem=elem&”</priority>”&VbCrLf
elem=elem& “</url>”&VbCrLf
rs.moveprevious
next
elem=elem& “</urlset>”
myxml=myxml&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″&DateMonth
If Len(DateDay)<2 Then DateDay=”0″&DateDay
If Len(DateMinute)<2 Then DateMinute=”0″&DateMinute
If Len(DateHour)<2 Then DateHour=”0″&DateHour
If Len(DateSecond)<2 Then DateSecond=”0″&DateSecond
ISO8601=Year(DateTime)&”-”&DateMonth&”-”&DateDay&”T”&DateHour&”:”&DateMinute&”:”&DateSecond&”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即可。
评论: 0 | 引用: 0 | 查看次数: -
发表评论