做值得信赖的网络营销服务运营商 专业

百度优化

 

搜索引擎优化

 

网站优化

 

seo优化

  您的位置:首页 >> 查查看剖析优化 >> Sitemap优化 >> Google网站地图生成代码
Google网站地图生成代码

        将下面的代码保存为sitemap.asp,然后放到网站根目录下,设定要生成的文件夹名字,运行,就OK了。

<%

' sitemap.asp

session("count")=0

'你的域名

session("server")="http://"&Request.ServerVariables("SERVER_NAME")

'制作生成SiteMap.xml的目录,后面不要带"/",大小写敏感

vDir = "SiteMap.xml"

'设置你想要GOOGLE收录的文件文件名扩展名

Extensions = Array("png","gif","jpg","jpeg","zip","pdf","ps","html","htm","asp","php","wk1","wk2","wk3","wk4","wk5","wki","wks","wku","lwp","mw","xls","ppt","doc","swf","wks","wps","wdb","wri","rtf","ans","txt","shtml","shtm")

'需要过滤的目录

PathExclusion=Array("\admin","\_vti_cnf","_vti_pvt","_vti_log","cgi-bin","aspnet_client")

set objfso = CreateObject("Scripting.FileSystemObject")

root = Server.MapPath(vDir)

'response.End

'创建文件

objfso.createtextfile(server.mappath(vDir))

response.write "<p><strong style='font-family:arial,sans-serif;font-size=12'>创建"&vDir&" 功!</strong><I style='font-family:arial,sans-serif;font-size=12'> "&server.mappath(vDir)&" </I></p>"

response.write "<p><strong style='font-family:arial,sans-serif;font-size=12'>正在索引文件,请稍侯...< /strong></p>"

Set openfileobj=objfso.opentextfile(server.mappath(vDir),8)

openfileobj.writeline"<?xml version='1.0' encoding='UTF-8'?>"

openfileobj.writeline"<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>"

'===

str=root

strLeft=split(str,vDir)(0)

'===

Set objFolder = objFSO.GetFolder(strLeft)

Set colFiles = objFolder.Files

For Each objFile In colFiles

openfileobj.writeline getfilelink(objFile.Path,objfile.dateLastModified)

Next

ShowSubFolders(objFolder)

openfileobj.writeline "</urlset>"

response.write "<p><strong style='font-family:arial,sans-serif;font-size=12'>"&vDir&"生成完 毕,共<span style=color:#FF0000> "&session("count")&" </span>个文件被索引</strong></p>"

set fso = nothing

Sub ShowSubFolders(objFolder)

Set colFolders = objFolder.SubFolders

For Each objSubFolder In colFolders

if folderpermission(objSubFolder.Path) then

openfileobj.writeline getfilelink(objSubFolder.Path,objSubFolder.dateLastModified)

Set colFiles = objSubFolder.Files

For Each objFile In colFiles

openfileobj.writeline getfilelink(objFile.Path,objFile.dateLastModified)

Next

ShowSubFolders(objSubFolder)

end if

Next

End Sub

Function getfilelink(file,datafile)

file=replace(file,root,"")

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)

strLeft=replace(strLeft,"\","/")

file=(split(LCASE(file),LCASE(strLeft)))(1)

getfilelink = "<url>"&Chr("10")&"<loc>"&server.htmlencode(session("server")&"/"&file)&"</loc>"&Chr("10")&"<lastmod>"&filedate&"</lastmod>"&Chr("10")&"<changefreq>daily</changefreq>"&Chr("10")&"<priority>1.0</priority>"&Chr("10")&"</url>"

session("count")=session("count")+"1"

Response.Flush

End Function

Function Folderpermission(pathName)

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

if len(trim(sFileName)) = 0 then

FileExtensionIsBad = true

Exit Function

end if

sFileExtension = right(sFileName, len(sFileName) - instrrev(sFileName, "."))

bFileExtensionIsValid = false

for each sFileExt in extensions

if ucase(sFileExt) = ucase(sFileExtension) then

bFileExtensionIsValid = True

exit for

end if

next

FileExtensionIsBad = not bFileExtensionIsValid

End Function

%>

  • 查查看观点
  • SEO行业动态
  • + 百度优化排名方式...
  • 百度排名方式可以大致分为3种,右侧竞价排名,左侧竞价排名,左侧自然排名。...
  • + 百度优化...
  • 百度优化的主要工作是通过了解各类百度如何抓取互联网页面...
  • + 网站优化和SEO的区别...
  • 网站优化的基本思想是:通过对网站功能、结构、布局、内容等关键要素的合理设计...
版权所有 查查看(北京)公关策划有限公司 Searchit(BeiJing)Network Technology Co., Ltd
经营许可证编号:(京)ICP证040636号 京ICP备10044773号-1 公安局备案号:1101084916 热门搜索:尚源堂 尚源堂官网 北京尚源堂 尚源堂量子生物科技 网站地图
律师顾问:北京市盈科律师事务所 魏镇胜