您所在的位置:小祥子 » 编程 » ASP » 正文

ASP生成百度地图示例

时间:2015-01-24 编辑:佚名 来源:互联网

如果你的程序是基于ASP的,那么下面的这段代码稍加修改就可以使用在你的程序上了,生成百度地图后可以加快搜索引擎收录。快试试吧~(PS:标准的XML地图也可以被百度识别,所以如果你的程序已经有了这功能就可以无视了。)

<%
nowtime=nowtime&"<updatetime>"&now()&"</updatetime>"&vbcrlf&""
'hour(now())
'minute(now())
'second(now())
set rshot=server.CreateObject("adodb.recordset")
sql="select * from 表名 order by id asc"
rshot.open sql,conn,1,1
if not (rshot.eof and rshot.bof) then
i=0
do while not rshot.eof
b=b&"<item>"&vbcrlf&""
b=b&"<link>http://www.xxx.com/test.html</link>"&vbcrlf&""
b=b&"<title>"&rshot("Title")&"</title>"&vbcrlf&""
b=b&"<pubDate>"&rshot("Intime")&" "&hour(now())&":"&minute(now())&":"&second(now())&"</pubDate>"&vbcrlf&""
b=b&"<bbs:lastDate>"&rshot("Intime")&" 10:26:42</bbs:lastDate>"&vbcrlf&""
b=b&"<bbs:reply>"&rshot("Classid")&"</bbs:reply>"&vbcrlf&""
b=b&"<bbs:hit>"&rshot("Hits")&"</bbs:hit>"&vbcrlf&""
b=b&"<bbs:mainLen>"&rshot("ID")&"</bbs:mainLen>"&vbcrlf&""
b=b&"<bbs:boardid>"&rshot("Author")&"</bbs:boardid>"&vbcrlf&""
b=b&"<bbs:pick>1</bbs:pick>"&vbcrlf&""
b=b&"</item>"&vbcrlf&""
i=i+1
rshot.movenext
loop
end if
rshot.close
set rshot=nothing
xmlfile=server.mappath("sitemap_baidu.xml")
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile(xmlfile,True)
MyFile.WriteLine("<?xml version=""1.0"" encoding=""GB2312"" ?>")
MyFile.WriteLine("<document xmlns:bbs=""http://www.baidu.com/search/bbs_sitemap.xsd"">")
MyFile.WriteLine("<webSite>http://www.xxx.net/</webSite>")
MyFile.WriteLine("<webMaster>admin@xxx.net</webMaster>")
MyFile.WriteLine("<updatePeri>12</updatePeri>")
MyFile.WriteLine nowtime
MyFile.WriteLine("<version>网站名称</version>")
MyFile.WriteLine b
MyFile.WriteLine("</document>")
MyFile.Close
response.Redirect("sitemap_baidu.xml")
%>