欢迎光临

桑三博客

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

作者: 桑三

日期: 2010-06-25 00:08 AM

分类: 电脑技术

内容: 在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]即可。

+ 查看当前日志评论 (0)

登录

────────────

桑三博客

PJBlog3 v3.2.9.518 Inside.

Processed In 0.363 ms

返回

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

发表评论:

昵称:
密码:
评论内容:

发表 返回

────────────

桑三博客

PJBlog3 v3.2.9.518 Inside.

Processed In 0.363 ms

返回

暂无评论

返回

────────────

桑三博客

PJBlog3 v3.2.9.518 Inside.

Processed In 0.379 ms

返回