找回密码
 注册
广告投放 虚位以待【阿里云】2核2G云新老同享 99元/年,续费同价做网站就用糖果主机-sugarhosts.comJtti.com-新加坡服务器,美国服务器,香港服务器
查看: 376|回复: 0

Google Sitemap更快更全面收录网站

[复制链接]
发表于 2006 年 5 月 24 日 16:46:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
google新推出的sitemap,是对原来robots.txt的扩展,sitemap!使用xml格式来记录整个网站的信息并供google读取,使搜索引擎能更快更全面的收录网站的内容。

    sitemap的作用就好像为网站提供了整站的rss,而google就是这些rss的订阅者,只要网站有更新就会自动通知google。这样一来,搜索引擎的收录由被动的pull变成了主动的push,辛苦的google爬虫们终于可以松一口气了。

    快来尝试下:https://www.google.com/webmasters/sitemaps/stats?hl=zh_CN

    有Gmail的可以用Gmail直接登录。登录后把生成的xml文件地址提交就可以了。

本站生成后的sitemap.xml文件地址为 http://www.popdu.net/Sitemap.xml

下面提供生成XML的Google SiteMap代码[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


session("server")=http://www.Popdu.net                '你的域名
vDir = "/"                                               '制作SiteMap的目录,相对目录(相对于根目录而言)


set objfso = CreateObject("Scripting.FileSystemObject")
r垃圾站 = 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/si ... ;>"

str = "<?xml version='1.0' encoding='UTF-8'?>" & vbcrlf
str = str & "<urlset xmlns='http://www.google.com/schemas/si ... ;>" & vbcrlf

Set objFolder = objFSO.GetFolder(r垃圾站)
'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,r垃圾站,"")
        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")&vDir&file)&"</loc><lastmod>"&filedate&"</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url>"
        Response.Flush
End Function


Function Folderpermission(pathName)

        '需要过滤的目录(不列在SiteMap里面)
        PathExclusion=Array("\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("png","gif","jpg","jpeg","zip","pdf","ps","html","htm","php","wk1","wk2","wk3","wk4","wk5","wki","wks","wku","lwp","mw","xls","ppt","doc","swf","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
%>


这样就有利于GOOGLE 的更快收录了:)
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|金光论坛

GMT+8, 2025 年 2 月 3 日 06:03 , Processed in 0.017124 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表