佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > google sitemap.asp

google sitemap.asp

熱門標(biāo)簽:服務(wù)器配置 Mysql連接數(shù)設(shè)置 電子圍欄 Linux服務(wù)器 銀行業(yè)務(wù) 團購網(wǎng)站 科大訊飛語音識別系統(tǒng) 阿里云
用于生成sitemap.xml文件的東西,利于google等搜索引擎的抓取。
復(fù)制代碼 代碼如下:

%
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")="https://www.jb51.net"
'你的域名
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('success!');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,"\","/")
file=replace(file,root,"")
If FileExtensionIsBad(file) then Exit Function
if month(datafile)10 then filedatem="0"
if day(datafile)10 then filedated="0"
filedate=year(datafile)"-"filedatemmonth(datafile)"-"filedatedday(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("\da@ta78#9","\member","\admin","\dxyeditor")
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")
'設(shè)置列表的文件名,擴展名不在其中的話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
%>
您可能感興趣的文章:
  • CodeIgniter使用phpcms模板引擎
  • CodeIgniter基本配置詳細(xì)介紹
  • CodeIgniter上傳圖片成功的全部過程分享
  • PHP生成sitemap.xml地圖函數(shù)
  • C#生成sitemap站點地圖的方法
  • dedecms實現(xiàn)仿downkr的sitemap效果代碼
  • 制做Google Sitemap文件的簡單方法與圖文教程
  • 用Google Sitemaps幫助你SEO
  • CodeIgniter生成網(wǎng)站sitemap地圖的方法

標(biāo)簽:棗莊 萍鄉(xiāng) 廣元 蚌埠 大理 衢州 江蘇 衡水

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《google sitemap.asp》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    板桥市| 枝江市| 洛隆县| 汉寿县| 莲花县| 江门市| 东山县| 漳浦县| 奈曼旗| 洛扎县| 长春市| 沅陵县| 克东县| 布拖县| 松原市| 会理县| 内江市| 德令哈市| 海阳市| 芦山县| 鄂托克前旗| 吉安市| 井冈山市| 南宁市| 安岳县| 邵阳市| 营口市| 怀宁县| 扬中市| 东乡| 庄浪县| 综艺| 依安县| 和硕县| 扬中市| 防城港市| 本溪| 开化县| 安阳县| 建阳市| 龙口市|