探索设计与体验的融合
Fusion design exploration and experience
新闻动态
News
好的网络营销公司会给客户提出建设性的意见,善于对客户进行良性引导
您的位置:>> 网站首页 >> 技术文章
番禺网站建设教你自动生成网站地图文件

    网站地图大家已不陌生,不过,在于现今流行网站优化的时代,对于不同的客户,可能所谓的“网站地图”意味着是不同的内容,例如,对于侧重于优化方面的网站,网站地图指的可能是类似小爬虫自动生生出来的sitemap.xml或sitemap.html的文件,给网络蜘蛛使用的“网站地图”;而对于侧重于用户友好度,帮助用户找到网站结构的目的,网站地图意味着是真正的一张“地图”,帮助访问者了解网站的整体结构。

    本次番禺网站建设为大家介绍的网站地图指的是前者,是给网络蜘蛛使用的“网站地图”,这种地图记录的信息很少,例如:http://www.py162.com/sitemap.xml,可以看到,只是一个简单的页面地图、更新频率、时间这三个参数,例如本站的一个例子,通过自动方式生成此网站地图:

<%
py162_html="<?xml version=""1.0"" encoding=""gb2312""?>"&VbCrLf
py162_html=py162_html&"<urlset"&VbCrLf
py162_html=py162_html&"    xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9"""&VbCrLf
py162_html=py162_html&"    xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"""&VbCrLf
py162_html=py162_html&"    xsi:schemaLocation=""http://www.sitemaps.org/schemas/sitemap/0.9"&VbCrLf
py162_html=py162_html&"       http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd""> "&VbCrLf

py162_html=py162_html&"<url>"&VbCrLf'开始的内容
py162_html=py162_html&"<loc>http://www.py162.com</loc>"&VbCrLf
py162_html=py162_html&"<priority>1.00</priority>"&VbCrLf
py162_html=py162_html&"<lastmod>"&get_date(now)&"</lastmod>"&VbCrLf
py162_html=py162_html&"<changefreq>daily</changefreq>"&VbCrLf
py162_html=py162_html&"</url>"&VbCrLf'结束的内容
py162_html=py162_html&"</urlset>"&VbCrLf

filename="sitemap.xml"
if py162_html<>"" then
'--------------------------------
'删除原来的文件
'--------------------------------
delefile=Server.MapPath(filename)  
Set fso=CreateObject("Scripting.FileSystemObject")  
if FSO.FileExists(delefile) then
fso.DeleteFile delefile 
end if 
Set fso=nothing
'--------------------------------

'--------------------------------
'建立文件
'--------------------------------
set fso = Server.CreateObject("Scripting.FileSystemObject")
set fout = fso.CreateTextFile(server.mappath(""&filename&""))
fout.write py162_html
fout.close
set fout=nothing
set fso=nothing
'--------------------------------
response.Write "<script language=javascript>alert('页面已生成!');window.close();</script>"
end if
%>


    相信大家的网站,都有很多页,可以将上面红色字的位置,写成循环的形式,将网站所有页面全部生成出来,那么,就是一张动态的网站地图了,可以自动生也sitemap.xml或sitemap.html文件,当有数据更新的时候,就执行一下,自动生成,您看,是不是很方便呢?

编辑:创意设计工作室 http://www.py162.com

相关链接>>
您对此文有什么评论?
类型: 意见建议 内容报错
网友对此文的评论:
未有评论!