2006-5-20 作者:佚名 来源:互联网 点击:7984
前一段时间在研究Google的SiteMap,做好了BLOG的SiteMp,并为此找了很多的文章来看,但发现很多的技术文章都是只管杀不管埋的,总有些错误,而有的则是不断的复制和粘贴,原著出在哪里都不知道,漏洞百出,也没有详细的说明,弄得郁闷死了,幸好还有一些热心的兄台给予指点,总算是完整了,溶入一些找到的相关知识,贴在这里供有需要的朋友分享一下。
Google SiteMap简介:
Google推出的Sitemap,是对原来robots.txt的扩展,它使用XML格式来记录整个网站的信息并供Google读取,使搜索引擎能更快更全面的收录网站的内容。Sitemap的作用就好像为网站提供了整站的RSS,而Google就是这些RSS的订阅者,只要网站有更新就会自动通知Google。这样一来,搜索引擎的收录由被动的Pull变成了主动的Push,辛苦的Google爬虫们终于可以松一口气了。
不过就目前来说,Google Sitemap还不是一个能让每个站长都方便使用的东西。其要求的XML格式虽不是很复杂,但要手工制作还是需要费不少功夫。虽然Google提供了Sitemap自动生成器,但目前只有python语言的版本, 能用上的也是少数,这个在实践中是得到了证实的,我看了N天都是一头雾水。不过Google Sitemap是按照创作共用协议发布的,Sitemap生成器也是开源的,所以相关的工具也很快出现了,我在网上就曾找到针对L-BLOG(此工具你可以参阅本博客[url=http://www.coosuo.com/blog/blogview.asp?logID=239&cateID=4]直接生成XML的Google SiteMap代码[ASP 4 LBLOG版本][/url]一文)、O-BLOG、DVBBS自动生成Sitemap的工具,只要简单的修改,各位站长和Blogger们就可以方便的使用这项服务了。
简单点说,就是你以XML的格式向Google提交一个站点地图,以后google就会根据这个地图,阶段性地抓取该地图指出的页面。抱怨google收入页面太少的朋友不妨一试。
以下是我找到的两个版本(ASP和PHP版)的网站SiteMap.xml生成工具,我现在用的就是以下ASP版的,经过测试了,我网站缘聚杭州生成的SiteMap文件:http://www.coosuo.com/SiteMap.xml,而下面的PHP版的代码,由于不是很懂,都没有测试过,大家可以试试如有错误,只有敬请谅解了!
ASP版代码:
程序代码
<%
Server.ScriptTimeout=50000
' sitemap_gen.asp
' A simple script to automatically produce sitemaps for a webserver‚ in the Google Sitemap Protocol (GSP)
' by Francesco Passantino
' www.iteam5.net/francesco/sitemap
' v0.2 released 5 june 2005 (Listing a directory tree recursively improvement)
'
' BSD 2.0 license‚
' http://www.opensource.org/licenses/bsd-license.php
' 收集整理: 重庆森林@im286.com
' 部分修改: 独人向晚QQ19433114
session("server")="http://www.coosuo.com" '你的域名
vDir = "/" '制作SiteMap的目录‚相对目录(相对于根目录而言)
set objfso = CreateObject("Scripting.FileSystemObject")
root = Server.MapPath(vDir)
'response.ContentType = "text/xml"
'response.write "<?xml version='1.0' encoding='UTF-8'?>"
'response.write "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>"
str = "<?xml version='1.0' encoding='UTF-8'?>" & vbcrlf
str = str & "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>" & vbcrlf
Set objFolder = objFSO.GetFolder(root)
'response.write getfilelink(objFolder.Path‚objFolder.dateLastModified)
Set colFiles = objFolder.Files
For Each objFile In colFiles
'response.write getfilelink(objFile.Path‚objfile.dateLastModified)
str = str & getfilelink(objFile.Path‚objfile.dateLastModified) & vbcrlf
Next
ShowSubFolders(objFolder)
'response.write "</urlset>"
str = str & "</urlset>" & vbcrlf
set fso = nothing
Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
'.Type = adTypeText
'.Mode = adModeReadWrite
.Open
.Charset = "utf-8"
.Position = objStream.Size
.WriteText=str
.SaveToFile server.mappath("/sitemap.xml")‚2 '生成的XML文件名
.Close
End With
Set objStream = Nothing
If Not Err Then
Response.Write("<script>alert('成功生成站点地图!');history.back();</script>")
Response.End
End If
Sub ShowSubFolders(objFolder)
Set colFolders = objFolder.SubFolders
For Each objSubFolder In colFolders
if folderpermission(objSubFolder.Path) then
'response.write getfilelink(objSubFolder.Path‚objSubFolder.dateLastModified)
str = str & getfilelink(objSubFolder.Path‚objSubFolder.dateLastModified) & vbcrlf
Set colFiles = objSubFolder.Files
For Each objFile In colFiles
'response.write getfilelink(objFile.Path‚objFile.dateLastModified)
str = str & getfilelink(objFile.Path‚objFile.dateLastModified) & vbcrlf
Next
ShowSubFolders(objSubFolder)
end if
Next
End Sub
Function getfilelink(file‚datafile)
file=replace(file‚root‚""‚1‚-1‚1)
file=replace(file‚"\"‚"/")
If FileExtensionIsBad(file) then Exit Function
if month(datafile)<10 then filedatem="0"
if day(datafile)<10 then filedated="0"
filedate=year(datafile)&"-"&filedatem&month(datafile)&"-"&filedated&day(datafile)
getfilelink = "<url><loc>"&server.htmlencode(session("server")&file)&"</loc><lastmod>"&filedate&"</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url>"
Response.Flush
End Function
Function Folderpermission(pathName)
'需要过滤的目录(不列在SiteMap里面)
PathExclusion=Array("\blog"‚"\temp"‚"\_vti_cnf"‚"_vti_pvt"‚"_vti_log"‚"cgi-bin"‚"\admin"‚"\edu")
Folderpermission =True
for each PathExcluded in PathExclusion
if instr(ucase(pathName)‚ucase(PathExcluded))>0 then
Folderpermission = False
exit for
end if
next
End Function
Function FileExtensionIsBad(sFileName)
Dim sFileExtension‚ bFileExtensionIsValid‚ sFileExt
'modify for your file extension (http://www.googleguide.com/file_type.html)
Extensions = Array("asp"‚"png"‚"jpeg"‚"zip"‚"pdf"‚"ps"‚"html"‚"htm"‚"php"‚"wk1"‚"wk2"‚"wk3"‚"wk4"‚"wk5"‚"wki"‚"wks"‚"wku"‚"lwp"‚"mw"‚"xls"‚"ppt"‚"doc"‚"wks"‚"wps"‚"wdb"‚"wri"‚"rtf"‚"ans"‚"txt")
'设置列表的文件名‚扩展名不在其中的话SiteMap则不会收录该扩展名的文件
if len(trim(sFileName)) = 0 then
FileExtensionIsBad = true
Exit Function
end if
sFileExtension = right(sFileName‚ len(sFileName) - instrrev(sFileName‚ "."))
bFileExtensionIsValid = false 'assume extension is bad
for each sFileExt in extensions
if ucase(sFileExt) = ucase(sFileExtension) then
bFileExtensionIsValid = True
exit for
end if
next
FileExtensionIsBad = not bFileExtensionIsValid
End Function
%>
PHP版代码:
程序代码
<?php
header('Content-type: application/xml; charset="GB2312"'‚true);
?>
<!--
@author Tobias Kluge‚ enarion.net
@version 0.2‚ 2005-06-05 17:40 PT
@status working
@update Aditya Naik‚ so1o@so1o.net
@Licence: LGPL
editor: MildSeven@im286.com
-->
<?php
$website = "http://my.xxxxx.com"; /* change this */
$page_root = "/usr/local/psa/home/vhosts/subdomains/my/httpdocs"; /* change this */
/* maybe change this: */
$changefreq = "weekly"; //"always"‚ "hourly"‚ "daily"‚ "weekly"‚ "monthly"‚ "yearly" and "never".
$priority = 0.8;
/* this sets the last modification date of all pages to the current date */
$last_modification = date("Y-m-d\TH:i:s") . substr(date("O")‚0‚3) . ":" . substr(date("O")‚3);
/* list of allowed directories */
$allow_dir[] = "web";
/* list of disallowed directories */
$disallow_dir[] = "admin";
$disallow_dir[] = "_notes";
/* list of disallowed file types */
$disallow_file[] = ".inc";
$disallow_file[] = ".old";
$disallow_file[] = ".save";
$disallow_file[] = ".txt";
$disallow_file[] = ".js";
$disallow_file[] = "~";
$disallow_file[] = ".LCK";
$disallow_file[] = ".zip";
$disallow_file[] = ".ZIP";
$disallow_file[] = ".CSV";
$disallow_file[] = ".csv";
$disallow_file[] = ".css";
$disallow_file[] = ".class";
$disallow_file[] = ".jar";
$disallow_file[] = ".mno";
$disallow_file[] = ".bak";
$disallow_file[] = ".lck";
$disallow_file[] = ".BAK";
/* simple compare function: equals */
function ar_contains($key‚ $array) {
foreach ($array as $val) {
if ($key == $val) {
return true;
}
}
return false;
}
/* better compare function: contains */
function fl_contains($key‚ $array) {
foreach ($array as $val) {
$pos = strpos($key‚ $val);
if ($pos === FALSE) continue;
return true;
}
return false;
}
/* this function changes a substring($old_offset) of each array element to $offset */
function changeOffset($array‚ $old_offset‚ $offset) {
$res = array();
foreach ($array as $val) {
$res[] = str_replace($old_offset‚ $offset‚ $val);
}
return $res;
}
/* this walks recursivly through all directories starting at page_root and
adds all files that fits the filter criterias */
// taken from Lasse Dalegaard‚ http://php.net/opendir
function getFiles($directory‚ $directory_orig = ""‚ $directory_offset="") {
global $disallow_dir‚ $disallow_file‚ $allow_dir;
if ($directory_orig == "") $directory_orig = $directory;
if($dir = opendir($directory)) {
// Create an array for all files found
$tmp = Array();
// Add the files
while($file = readdir($dir)) {
// Make sure the file exists
if($file != "." && $file != ".." && $file[0] != '.' ) {
// If it's a directiry‚ list all files within it
//echo "point1<br>";
if(is_dir($directory . "/" . $file)) {
//echo "point2<br>";
$disallowed_abs = fl_contains($directory."/".$file‚ $disallow_dir); // handle directories with pathes
$disallowed = ar_contains($file‚ $disallow_dir); // handle directories only without pathes
$allowed_abs = fl_contains($directory."/".$file‚ $allow_dir);
$allowed = ar_contains($file‚ $allow_dir);
if ($disallowed || $disallowed_abs) continue;
if ($allowed_abs || $allowed){
$tmp2 = changeOffset(getFiles($directory . "/" . $file‚ $directory_orig‚ $directory_offset)‚ $directory_orig‚ $directory_offset);
if(is_array($tmp2)) {
$tmp = array_merge($tmp‚ $tmp2);
}
}
} else { // files
if (fl_contains($file‚ $disallow_file)) continue;
array_push($tmp‚ str_replace($directory_orig‚ $directory_offset‚ $directory."/".$file));
}
}
}
// Finish off the function
closedir($dir);
return $tmp;
}
}
$a = getFiles($page_root);
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<?
foreach ($a as $file) {
?>
<url>
<loc><? echo utf8_encode($website.$file); ?></loc>
<lastmod><? echo utf8_encode(date("Y-m-d\TH:i:s"‚ filectime($page_root.$file)). substr(date("O")‚0‚3) . ":" . substr(date("O")‚3));?></lastmod>
<changefreq><? echo utf8_encode($changefreq); ?></changefreq>
<priority><? echo utf8_encode($priority); ?></priority>
</url>
<?
}
?>
</urlset>
参数说明:
$website--你的域名
$page_root--你的站点的绝对路径
$changefreq--更新时间单位 "always"(始终)‚ "hourly"(小时)‚ "daily"(天)‚ "weekly"(星期)‚ "monthly"(月)‚ "yearly" "never"(从不)
$priority--更新频率
$allow_dir--允许列表的目录
$disallow_dir--禁止列表的目录
$disallow_file--禁止列表的文件类型
制作过程说明:
将以上代码复制到本地存为sitemap.asp或sitemap.php,上传到你的服务器网站的根目录下,运行一下就可以在你指定的目录中(建议最好是指定为根目录)自动生成一个sitemap.xml文件了。最后进入google提交页面:https://www.google.com/webmasters/sitemaps/login,有gmail的可以用gmail直接登录。登录后把生成的xml文件地址按步骤提交就可以了。注:你的网站如果增加了新的页面,可以在增加完后再运行一下sitemap.asp或sitemap.php,并再重新提交一下sitemap.xml文件,这样就可以保证sitemap.xml文件的不断更新了!
相关网址:
Google SiteMap官方生成器及其说明:http://sourceforge.net/project/showfiles.php?group_id=137793&package_id=153422
Google 的相关探索与研究:http://www.netbei.com/Article/zz/zz6/google/Index.html
一种手动制作分析制作SiteMap方法:http://blog.blogchina.com/hooligan/3609116.html
另一个PHP版的sitemap生成程序:
点击下载
运行界面:
==================================================================
自动生成符合GOOGLE要求的网站地图文件
Copyright Top flood
原作者 :
Kloh : TimeSplitters' Games; ImmortalPC :Immortal-PC
Laozei汉化整理 - IP查询、手机地理位置查询、身份证查询
注:
1.请把本程序放入网站根目录执行
2.程序执行前请修改如下参数(或常量)以符合你网站要求:
LIMITLIENPARFICHIER
LIMITLIENINDEXE
$ExtensionsAutorises
$DossiersInterdits
$FichiersInterdits
3.程序将把列表写入多个xml文件(如果你网页比较多的话)
4.sitemap(x).xml文件将写入根目录
URL列表(将写入sitemap)中。。。
./feed.php
./index.php
./error.php
./guestbook.php
./read.php
./tag.php
./tb.php
./view.php
./visit.php
9 行网址将被写入sitemap文件.
sitemap.xml文件生成完毕...
生成文件 sitemap.xml
全部生成完毕
Google SiteMap简介:
Google推出的Sitemap,是对原来robots.txt的扩展,它使用XML格式来记录整个网站的信息并供Google读取,使搜索引擎能更快更全面的收录网站的内容。Sitemap的作用就好像为网站提供了整站的RSS,而Google就是这些RSS的订阅者,只要网站有更新就会自动通知Google。这样一来,搜索引擎的收录由被动的Pull变成了主动的Push,辛苦的Google爬虫们终于可以松一口气了。
不过就目前来说,Google Sitemap还不是一个能让每个站长都方便使用的东西。其要求的XML格式虽不是很复杂,但要手工制作还是需要费不少功夫。虽然Google提供了Sitemap自动生成器,但目前只有python语言的版本, 能用上的也是少数,这个在实践中是得到了证实的,我看了N天都是一头雾水。不过Google Sitemap是按照创作共用协议发布的,Sitemap生成器也是开源的,所以相关的工具也很快出现了,我在网上就曾找到针对L-BLOG(此工具你可以参阅本博客[url=http://www.coosuo.com/blog/blogview.asp?logID=239&cateID=4]直接生成XML的Google SiteMap代码[ASP 4 LBLOG版本][/url]一文)、O-BLOG、DVBBS自动生成Sitemap的工具,只要简单的修改,各位站长和Blogger们就可以方便的使用这项服务了。
简单点说,就是你以XML的格式向Google提交一个站点地图,以后google就会根据这个地图,阶段性地抓取该地图指出的页面。抱怨google收入页面太少的朋友不妨一试。
以下是我找到的两个版本(ASP和PHP版)的网站SiteMap.xml生成工具,我现在用的就是以下ASP版的,经过测试了,我网站缘聚杭州生成的SiteMap文件:http://www.coosuo.com/SiteMap.xml,而下面的PHP版的代码,由于不是很懂,都没有测试过,大家可以试试如有错误,只有敬请谅解了!
ASP版代码:
程序代码
<%
Server.ScriptTimeout=50000
' sitemap_gen.asp
' A simple script to automatically produce sitemaps for a webserver‚ in the Google Sitemap Protocol (GSP)
' by Francesco Passantino
' www.iteam5.net/francesco/sitemap
' v0.2 released 5 june 2005 (Listing a directory tree recursively improvement)
'
' BSD 2.0 license‚
' http://www.opensource.org/licenses/bsd-license.php
' 收集整理: 重庆森林@im286.com
' 部分修改: 独人向晚QQ19433114
session("server")="http://www.coosuo.com" '你的域名
vDir = "/" '制作SiteMap的目录‚相对目录(相对于根目录而言)
set objfso = CreateObject("Scripting.FileSystemObject")
root = Server.MapPath(vDir)
'response.ContentType = "text/xml"
'response.write "<?xml version='1.0' encoding='UTF-8'?>"
'response.write "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>"
str = "<?xml version='1.0' encoding='UTF-8'?>" & vbcrlf
str = str & "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>" & vbcrlf
Set objFolder = objFSO.GetFolder(root)
'response.write getfilelink(objFolder.Path‚objFolder.dateLastModified)
Set colFiles = objFolder.Files
For Each objFile In colFiles
'response.write getfilelink(objFile.Path‚objfile.dateLastModified)
str = str & getfilelink(objFile.Path‚objfile.dateLastModified) & vbcrlf
Next
ShowSubFolders(objFolder)
'response.write "</urlset>"
str = str & "</urlset>" & vbcrlf
set fso = nothing
Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
'.Type = adTypeText
'.Mode = adModeReadWrite
.Open
.Charset = "utf-8"
.Position = objStream.Size
.WriteText=str
.SaveToFile server.mappath("/sitemap.xml")‚2 '生成的XML文件名
.Close
End With
Set objStream = Nothing
If Not Err Then
Response.Write("<script>alert('成功生成站点地图!');history.back();</script>")
Response.End
End If
Sub ShowSubFolders(objFolder)
Set colFolders = objFolder.SubFolders
For Each objSubFolder In colFolders
if folderpermission(objSubFolder.Path) then
'response.write getfilelink(objSubFolder.Path‚objSubFolder.dateLastModified)
str = str & getfilelink(objSubFolder.Path‚objSubFolder.dateLastModified) & vbcrlf
Set colFiles = objSubFolder.Files
For Each objFile In colFiles
'response.write getfilelink(objFile.Path‚objFile.dateLastModified)
str = str & getfilelink(objFile.Path‚objFile.dateLastModified) & vbcrlf
Next
ShowSubFolders(objSubFolder)
end if
Next
End Sub
Function getfilelink(file‚datafile)
file=replace(file‚root‚""‚1‚-1‚1)
file=replace(file‚"\"‚"/")
If FileExtensionIsBad(file) then Exit Function
if month(datafile)<10 then filedatem="0"
if day(datafile)<10 then filedated="0"
filedate=year(datafile)&"-"&filedatem&month(datafile)&"-"&filedated&day(datafile)
getfilelink = "<url><loc>"&server.htmlencode(session("server")&file)&"</loc><lastmod>"&filedate&"</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url>"
Response.Flush
End Function
Function Folderpermission(pathName)
'需要过滤的目录(不列在SiteMap里面)
PathExclusion=Array("\blog"‚"\temp"‚"\_vti_cnf"‚"_vti_pvt"‚"_vti_log"‚"cgi-bin"‚"\admin"‚"\edu")
Folderpermission =True
for each PathExcluded in PathExclusion
if instr(ucase(pathName)‚ucase(PathExcluded))>0 then
Folderpermission = False
exit for
end if
next
End Function
Function FileExtensionIsBad(sFileName)
Dim sFileExtension‚ bFileExtensionIsValid‚ sFileExt
'modify for your file extension (http://www.googleguide.com/file_type.html)
Extensions = Array("asp"‚"png"‚"jpeg"‚"zip"‚"pdf"‚"ps"‚"html"‚"htm"‚"php"‚"wk1"‚"wk2"‚"wk3"‚"wk4"‚"wk5"‚"wki"‚"wks"‚"wku"‚"lwp"‚"mw"‚"xls"‚"ppt"‚"doc"‚"wks"‚"wps"‚"wdb"‚"wri"‚"rtf"‚"ans"‚"txt")
'设置列表的文件名‚扩展名不在其中的话SiteMap则不会收录该扩展名的文件
if len(trim(sFileName)) = 0 then
FileExtensionIsBad = true
Exit Function
end if
sFileExtension = right(sFileName‚ len(sFileName) - instrrev(sFileName‚ "."))
bFileExtensionIsValid = false 'assume extension is bad
for each sFileExt in extensions
if ucase(sFileExt) = ucase(sFileExtension) then
bFileExtensionIsValid = True
exit for
end if
next
FileExtensionIsBad = not bFileExtensionIsValid
End Function
%>
PHP版代码:
程序代码
<?php
header('Content-type: application/xml; charset="GB2312"'‚true);
?>
<!--
@author Tobias Kluge‚ enarion.net
@version 0.2‚ 2005-06-05 17:40 PT
@status working
@update Aditya Naik‚ so1o@so1o.net
@Licence: LGPL
editor: MildSeven@im286.com
-->
<?php
$website = "http://my.xxxxx.com"; /* change this */
$page_root = "/usr/local/psa/home/vhosts/subdomains/my/httpdocs"; /* change this */
/* maybe change this: */
$changefreq = "weekly"; //"always"‚ "hourly"‚ "daily"‚ "weekly"‚ "monthly"‚ "yearly" and "never".
$priority = 0.8;
/* this sets the last modification date of all pages to the current date */
$last_modification = date("Y-m-d\TH:i:s") . substr(date("O")‚0‚3) . ":" . substr(date("O")‚3);
/* list of allowed directories */
$allow_dir[] = "web";
/* list of disallowed directories */
$disallow_dir[] = "admin";
$disallow_dir[] = "_notes";
/* list of disallowed file types */
$disallow_file[] = ".inc";
$disallow_file[] = ".old";
$disallow_file[] = ".save";
$disallow_file[] = ".txt";
$disallow_file[] = ".js";
$disallow_file[] = "~";
$disallow_file[] = ".LCK";
$disallow_file[] = ".zip";
$disallow_file[] = ".ZIP";
$disallow_file[] = ".CSV";
$disallow_file[] = ".csv";
$disallow_file[] = ".css";
$disallow_file[] = ".class";
$disallow_file[] = ".jar";
$disallow_file[] = ".mno";
$disallow_file[] = ".bak";
$disallow_file[] = ".lck";
$disallow_file[] = ".BAK";
/* simple compare function: equals */
function ar_contains($key‚ $array) {
foreach ($array as $val) {
if ($key == $val) {
return true;
}
}
return false;
}
/* better compare function: contains */
function fl_contains($key‚ $array) {
foreach ($array as $val) {
$pos = strpos($key‚ $val);
if ($pos === FALSE) continue;
return true;
}
return false;
}
/* this function changes a substring($old_offset) of each array element to $offset */
function changeOffset($array‚ $old_offset‚ $offset) {
$res = array();
foreach ($array as $val) {
$res[] = str_replace($old_offset‚ $offset‚ $val);
}
return $res;
}
/* this walks recursivly through all directories starting at page_root and
adds all files that fits the filter criterias */
// taken from Lasse Dalegaard‚ http://php.net/opendir
function getFiles($directory‚ $directory_orig = ""‚ $directory_offset="") {
global $disallow_dir‚ $disallow_file‚ $allow_dir;
if ($directory_orig == "") $directory_orig = $directory;
if($dir = opendir($directory)) {
// Create an array for all files found
$tmp = Array();
// Add the files
while($file = readdir($dir)) {
// Make sure the file exists
if($file != "." && $file != ".." && $file[0] != '.' ) {
// If it's a directiry‚ list all files within it
//echo "point1<br>";
if(is_dir($directory . "/" . $file)) {
//echo "point2<br>";
$disallowed_abs = fl_contains($directory."/".$file‚ $disallow_dir); // handle directories with pathes
$disallowed = ar_contains($file‚ $disallow_dir); // handle directories only without pathes
$allowed_abs = fl_contains($directory."/".$file‚ $allow_dir);
$allowed = ar_contains($file‚ $allow_dir);
if ($disallowed || $disallowed_abs) continue;
if ($allowed_abs || $allowed){
$tmp2 = changeOffset(getFiles($directory . "/" . $file‚ $directory_orig‚ $directory_offset)‚ $directory_orig‚ $directory_offset);
if(is_array($tmp2)) {
$tmp = array_merge($tmp‚ $tmp2);
}
}
} else { // files
if (fl_contains($file‚ $disallow_file)) continue;
array_push($tmp‚ str_replace($directory_orig‚ $directory_offset‚ $directory."/".$file));
}
}
}
// Finish off the function
closedir($dir);
return $tmp;
}
}
$a = getFiles($page_root);
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<?
foreach ($a as $file) {
?>
<url>
<loc><? echo utf8_encode($website.$file); ?></loc>
<lastmod><? echo utf8_encode(date("Y-m-d\TH:i:s"‚ filectime($page_root.$file)). substr(date("O")‚0‚3) . ":" . substr(date("O")‚3));?></lastmod>
<changefreq><? echo utf8_encode($changefreq); ?></changefreq>
<priority><? echo utf8_encode($priority); ?></priority>
</url>
<?
}
?>
</urlset>
参数说明:
$website--你的域名
$page_root--你的站点的绝对路径
$changefreq--更新时间单位 "always"(始终)‚ "hourly"(小时)‚ "daily"(天)‚ "weekly"(星期)‚ "monthly"(月)‚ "yearly" "never"(从不)
$priority--更新频率
$allow_dir--允许列表的目录
$disallow_dir--禁止列表的目录
$disallow_file--禁止列表的文件类型
制作过程说明:
将以上代码复制到本地存为sitemap.asp或sitemap.php,上传到你的服务器网站的根目录下,运行一下就可以在你指定的目录中(建议最好是指定为根目录)自动生成一个sitemap.xml文件了。最后进入google提交页面:https://www.google.com/webmasters/sitemaps/login,有gmail的可以用gmail直接登录。登录后把生成的xml文件地址按步骤提交就可以了。注:你的网站如果增加了新的页面,可以在增加完后再运行一下sitemap.asp或sitemap.php,并再重新提交一下sitemap.xml文件,这样就可以保证sitemap.xml文件的不断更新了!
相关网址:
Google SiteMap官方生成器及其说明:http://sourceforge.net/project/showfiles.php?group_id=137793&package_id=153422
Google 的相关探索与研究:http://www.netbei.com/Article/zz/zz6/google/Index.html
一种手动制作分析制作SiteMap方法:http://blog.blogchina.com/hooligan/3609116.html
另一个PHP版的sitemap生成程序:
点击下载
运行界面:
==================================================================
自动生成符合GOOGLE要求的网站地图文件
Copyright Top flood
原作者 :
Kloh : TimeSplitters' Games; ImmortalPC :Immortal-PC
Laozei汉化整理 - IP查询、手机地理位置查询、身份证查询
注:
1.请把本程序放入网站根目录执行
2.程序执行前请修改如下参数(或常量)以符合你网站要求:
LIMITLIENPARFICHIER
LIMITLIENINDEXE
$ExtensionsAutorises
$DossiersInterdits
$FichiersInterdits
3.程序将把列表写入多个xml文件(如果你网页比较多的话)
4.sitemap(x).xml文件将写入根目录
URL列表(将写入sitemap)中。。。
./feed.php
./index.php
./error.php
./guestbook.php
./read.php
./tag.php
./tb.php
./view.php
./visit.php
9 行网址将被写入sitemap文件.
sitemap.xml文件生成完毕...
生成文件 sitemap.xml
全部生成完毕
声明:本站刊载此文不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。如有疑问请与站长联系。
相关链接更多...
- XMLHTTP详细介绍2006-5-20
- xmlhttp上传文件突破大小限制2006-5-20
- ASP生成具有分页的静态网页2006-5-20
- Server.ScriptTimeOut:处理脚本运行时间的方法2006-5-20
- 韩国象素画欣赏[图]2006-5-20
- Google SiteMap生成工具 (ASP & PHP)2006-5-20
- 用正则表达式突出显示字符串中查询到的单词的函数2006-5-20
- 一份ASP释放内存的的实验报告[图]2006-5-20
- ASP封装成DLL一些注意事项2006-5-20
- 用VB 6封装ASP代码, 制作DLL组件2006-5-20
全站精华
- 地产广告1[图]
- 经典室内设计作品--宫殿风格1[图]
- 朱峰手绘插画欣赏--场景篇(Environments)(1)[图]
- 朱峰手绘插画-角色篇(Characters)(十三)[图]
- 朱峰手绘插画-角色篇(Characters)(一)[图]
- 景观设计城市公园:浙江黄岩永宁公园(3)[图]
- 人像摄影:《炫影》(3)[图]
- 人像摄影:《炫影》(2)[图]
- 人像摄影:《炫影》(1)[图]
- asp远程图片自动上传到服务器
- 韩国品牌YSB夏装 冷艳美人异国风情(3)[图]
- MIKE H的CG插画作品欣赏(3)[图]
- MIKE H的CG插画作品欣赏(2)[图]
- MIKE H的CG插画作品欣赏(1)[图]
- 塑造完美—最美丽的CG女孩 [图]
- Google SiteMap生成工具 (ASP & PHP)
- ASP生成具有分页的静态网页
- 《星战》原版手绘作品欣赏--电影中看不到的经典[图]
- 经典海报设计欣赏1[图]
- 经典T恤设计欣赏3[图]
- 人体摄影欣赏(一个人的村庄)1[图]
- 欧洲品牌服装OLIVIER STRELLI[图]
- 2006泳装时尚,沙滩上的艳遇1[图]
- 香港著名设计师韩秉华[图]
- 韩秉华经典海报设计欣赏1[图]
- 2003戛纳广告节优秀平面作品展1[图]
- 手绘效果图精品1[图]
- 访数码跳跃BOSS钟海腾[图]
- 中国画-水浒人物画(戴敦邦)1[图]
- 韩国插画欣赏[图]
图文精彩

【2006-5-10 18:31:05】
风景摄影欣赏molnies 1
风景摄影欣赏molnies 1
![人像摄影:《炫影》(1)[图]--摄影艺术](http://www.fansart.com/uploadfile/20065966294533.gif)
【2006-5-9 18:18:49】
人像摄影:《炫影》(1)
人像摄影:《炫影》(1)

【2006-5-8 11:37:48】
韩国品牌YSB夏装 冷艳美人异国风情(3)
韩国品牌YSB夏装 冷艳美人异国风情(3)

【2006-5-8 9:52:42】
MIKE H的CG插画作品欣赏(1)
MIKE H的CG插画作品欣赏(1)
![经典样本设计欣赏(国人作品)1[图]--平面广告](http://www.fansart.com/uploadfile/200642664631465.jpg)
【2006-4-26 17:57:18】
经典样本设计欣赏(国人作品)1
经典样本设计欣赏(国人作品)1

【2006-4-26 14:27:13】
新锐CG插画 Monday to Friday
新锐CG插画 Monday to Friday

【2006-4-26 13:34:46】
Natascha Roeoesli的人物CG插画作品欣赏(1)
Natascha Roeoesli的人物CG插画作品欣赏(1)
![水木清华地产广告欣赏[图]--平面广告](http://www.fansart.com/uploadfile/200642634295921.jpg)
【2006-4-26 9:31:54】
水木清华地产广告欣赏
水木清华地产广告欣赏
![2006夏日流行时尚,创意无限街头华丽[图]--时装魅影](http://www.fansart.com/uploadfile/200642261089093.jpg)
【2006-4-22 16:46:51】
2006夏日流行时尚,创意无限街头华丽
2006夏日流行时尚,创意无限街头华丽
![万科西山庭院.格.沉.尊[图]--平面广告](http://www.fansart.com/uploadfile/200642133015939.jpg)
【2006-4-21 9:08:35】
万科西山庭院.格.沉.尊
万科西山庭院.格.沉.尊
![泊林花园推广故事绘本(2)[图]--CG插画](http://www.fansart.com/uploadfile/200642042197577.jpg)
【2006-4-20 11:43:23】
泊林花园推广故事绘本(2)
泊林花园推广故事绘本(2)
![泊林花园推广故事绘本(1)[图]--CG插画](http://www.fansart.com/uploadfile/200642041664949.jpg)
【2006-4-20 11:34:33】
泊林花园推广故事绘本(1)
泊林花园推广故事绘本(1)
![房地产广告设计-之水墨风格1[图]--平面广告](http://www.fansart.com/uploadfile/200641457308753.jpg)
【2006-4-14 15:56:06】
房地产广告设计-之水墨风格1
房地产广告设计-之水墨风格1
![溯源居广告欣赏--小红人[图]--平面广告](http://www.fansart.com/uploadfile/200641453136345.jpg)
【2006-4-14 14:45:57】
溯源居广告欣赏--小红人
溯源居广告欣赏--小红人
![cg插画欣赏[图]--CG插画](http://www.fansart.com/uploadfile/200641433658593.jpg)
【2006-4-14 9:21:18】
cg插画欣赏
cg插画欣赏
![yashasi插画作品欣赏[图]--CG插画](http://www.fansart.com/uploadfile/200641366906025.jpg)
【2006-4-13 18:32:29】
yashasi插画作品欣赏
yashasi插画作品欣赏
![北邦插画欣赏(1)[图]--CG插画](http://www.fansart.com/uploadfile/200641335800545.jpg)
【2006-4-13 9:49:02】
北邦插画欣赏(1)
北邦插画欣赏(1)
![高傲的玫瑰-温碧霞[图]--摄影艺术](http://www.fansart.com/uploadfile/200641232299455.jpg)
【2006-4-12 8:58:34】
高傲的玫瑰-温碧霞
高傲的玫瑰-温碧霞
![国粹京剧脸谱表情[图]--界面设计](http://www.fansart.com/uploadfile/200641164370797.jpg)
【2006-4-11 17:51:33】
国粹京剧脸谱表情
国粹京剧脸谱表情
![回忆紫禁城里那些逝去的[图]--中国艺术](http://www.fansart.com/uploadfile/200641159463469.jpg)
【2006-4-11 16:34:31】
回忆紫禁城里那些逝去的
回忆紫禁城里那些逝去的