西安网站建设使用asp生成百度以及谷歌SITEMAP的xml代码

19522012-05-16

[codes]

西安网站建设使用asp生成百度的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.mycodes.net/html/"&rshot("Classid")&"/"&rshot("ID")&".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.mycodes.net/</webSite>")
MyFile.WriteLine("<webMaster>admin@mycodes.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")
%>

[/codes]


[codes]

西安网站建设使用asp生成谷歌的xml代码
<%
Response.Buffer = True
With Response
 .Expires = -1
 .AddHeader "Pragma","no-cache"
 .AddHeader "cache-ctrol","no-cache"
End With
%>
<%
Server.ScriptTimeout=50000

Dim str,objStream
str = "<?xml version='1.0' encoding='UTF-8'?>" & vbcrlf
str = str & "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>" & vbcrlf
str = str & getfilelink & vbcrlf
str = str & "</urlset>" & vbcrlf

Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
.Open
.Charset = "UTF-8"
.Position = objStream.Size
.WriteText=str
.SaveToFile server.mappath("sitemap.xml"),2
.Close
End With
Set objStream = Nothing

If Not Err Then
   Response.Redirect("sitemap.xml")
   Response.End
End If

Function getfilelink()
   SQL="SELECT * FROM 表名 ORDER BY id DESC"
   Dim RS
   Set RS=Server.CreateObject("ADODB.RecordSet")
   RS.Open SQL,Conn,1,1

   IF RS.EOF AND RS.BOF Then
      Response.Write("<url></url>")
   Else
      Do While NOT RS.EOF
   Y=year(RS("intime"))
   if len(month(RS("intime")))=1 then
   M=0&month(RS("intime"))
   else
   M=month(RS("intime"))
   end if
   if len(day(RS("intime")))=1 then
   D=0&day(RS("intime"))
   else
   D=day(RS("intime"))
   end if
          getfilelink = getfilelink & "<url><loc>http://www.mycodes.net/html/"&RS("Classid")&"/"&RS("ID")&".Html</loc><lastmod>"&Y&"-"&M&"-"&D&"</lastmod><changefreq>"&RS("Title")&"</changefreq><priority>1.0</priority></url>"
          RS.MoveNext
      Loop
   End IF
RS.Close
Set RS=Nothing
Conn.Close
Set Conn=Nothing
End Function
%>

[/codes]

通过本文您对西安网站建设有了进一步了解,本公司温馨提醒:找西安做网站公司,请选择手续齐全、业务精、服务好的正规公司。

工商网上亮照

版权所有:西安点墨网络科技有限公司 信息备案编号: 陕ICP备11004160号-1

客户服务电话:15229292610

公司注册地址:西安市雁塔区融鑫路丽湾蓝岛1幢3单元16层31605号

临时办公地址:西安市雁塔区朱雀大街紫郡长安F3

Sitemap 网站地图 手机版

服务热线:15229292610

客服信箱:vip@dianmo.cc

846461336327

版权所有:西安点墨网络科技有限公司 信息备案编号: 陕ICP备11004160号-1