主頁(yè) > 知識(shí)庫(kù) > 適合所有網(wǎng)站的rss和xml聚合功能asp代碼

適合所有網(wǎng)站的rss和xml聚合功能asp代碼

熱門標(biāo)簽:騰訊地圖標(biāo)注商戶關(guān)閉 長(zhǎng)沙防封電銷卡品牌 智能電銷機(jī)器人適用于哪些行業(yè) 地圖標(biāo)注服務(wù)哪家好 地圖標(biāo)注宅基地 徐州人工智能電銷機(jī)器人好用嗎 武漢營(yíng)銷電話機(jī)器人軟件 西寧公司外呼系統(tǒng)平臺(tái) 外呼系統(tǒng)還用卡么
rss.asp格式的
下面代碼保存為rss.asp
復(fù)制代碼 代碼如下:

!--#include file="conn.asp"-->
%
strURL = "http://" request.servervariables("server_name") _
left(request.servervariables("script_name"),len(request.servervariables("SCRIPT_NAME"))-len("/rss.asp")) //中的/rss.asp為你的該文件名

sql="select top 100 * from [表名] order by id desc" //根據(jù)自己實(shí)際修改,top 100 為最新100條,自己修改,同時(shí)可以增加查詢條件,如where xxx=1....
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
response.contenttype="text/xml"
response.write "?xml version=""1.0"" encoding=""gb2312"" ?>" vbcrlf
response.write "rss version=""2.0"">" vbcrlf
response.write "channel>" vbcrlf
response.write "title>xxx.com RSS feed/title>" vbcrlf
response.write "link>" strURL "/link>" vbcrlf
response.write "language>zh-cn/language>" vbcrlf
response.write "copyright>An RSS feed for xxx.comcopyright>" vbcrlf
while not rs.eof
response.write "item>" vbcrlf
response.write "title>![CDATA[" rs("title") "]]>/title>" vbcrlf
response.write "link>"strURL"/xxxx.asp?Id="rs("id")"/link>" vbcrlf
response.write "description>![CDATA[" rs("主題字段") "br />" rs("內(nèi)容字段") "br />br />]]>/description>" vbcrlf
response.write "pubDate>" return_RFC822_Date(rs("時(shí)間字段"),"GMT") "/pubDate>" vbcrlf
response.write "/item>" vbcrlf
rs.movenext
wend
response.write "/channel>" vbcrlf
response.write "/rss>" vbcrlf
rs.close
set rs=nothing

Function return_RFC822_Date(byVal myDate, byVal TimeZone)
Dim myDay, myDays, myMonth, myYear
Dim myHours, myMinutes, mySeconds

myDate = CDate(myDate)
myDay = EnWeekDayName(myDate)
myDays = Right("00" Day(myDate),2)
myMonth = EnMonthName(myDate)
myYear = Year(myDate)
myHours = Right("00" Hour(myDate),2)
myMinutes = Right("00" Minute(myDate),2)
mySeconds = Right("00" Second(myDate),2)


return_RFC822_Date = myDay", " _
myDays" " _
myMonth" " _
myYear" " _
myHours":" _
myMinutes":" _
mySeconds" " _
" " TimeZone
End Function

Function EnWeekDayName(InputDate)
Dim Result
Select Case WeekDay(InputDate,1)
Case 1:Result="Sun"
Case 2:Result="Mon"
Case 3:Result="Tue"
Case 4:Result="Wed"
Case 5:Result="Thu"
Case 6:Result="Fri"
Case 7:Result="Sat"
End Select
EnWeekDayName = Result
End Function

Function EnMonthName(InputDate)
Dim Result
Select Case Month(InputDate)
Case 1:Result="Jan"
Case 2:Result="Feb"
Case 3:Result="Mar"
Case 4:Result="Apr"
Case 5:Result="May"
Case 6:Result="Jun"
Case 7:Result="Jul"
Case 8:Result="Aug"
Case 9:Result="Sep"
Case 10:Result="Oct"
Case 11:Result="Nov"
Case 12:Result="Dec"
End Select
EnMonthName = Result
End Function
%>

rss.xml格式的
復(fù)制代碼 代碼如下:

!--#include file="conn.asp"-->
%
strURL = "http://" request.servervariables("SERVER_NAME") _
left(request.servervariables("SCRIPT_NAME"),len(request.servervariables("SCRIPT_NAME"))-len("/rss.asp"))
dim foolcat,js
set js = server.CreateObject("ADODB.RecordSet")
sql = "select * from [表名] order by id asc"
set js = conn.execute (sql)

foolcat = foolcat + "?xml version=""1.0"" encoding=""UTF-8"" ?>"
foolcat = foolcat + "rss version=""2.0"">"
foolcat = foolcat + "channel>"
foolcat = foolcat + "title>xxx.com XML feed/title>"
foolcat = foolcat + "link>" strURL "/link>"
foolcat = foolcat + "language>zh-cn/language>"
foolcat = foolcat + "copyright>An XML feed for xxx.com/copyright>"
do until js.eof
foolcat = foolcat + "item>"
foolcat = foolcat + "title>![CDATA[" rs("主題字段") "]]>/title>"
foolcat = foolcat + "description>![CDATA[" rs("主題字段") "br />" rs("內(nèi)容字段") "br />br />]]>/description>"
foolcat = foolcat + "link>" strURL "/xxx.asp?Id="rs("id字段")"/link>"
foolcat = foolcat + "pubDate>" rs("時(shí)間字段") "/pubDate>"
foolcat = foolcat + "/item>"
js.movenext
loop
js.close
set js = nothing
foolcat = foolcat + "/channel>"
foolcat = foolcat + "/rss>"
foolcat = "" + foolcat + ""
foolcat = "" foolcat ""
FolderPath = Server.MapPath("/")
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.CreateTextFile(FolderPath"\rss.xml")
fout.writeLine foolcat
fout.close
set fout = nothing
conn.close
set conn = nothing
%>

標(biāo)簽:荊門 雅安 通化 通遼 運(yùn)城 巴彥淖爾 鷹潭 普洱

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《適合所有網(wǎng)站的rss和xml聚合功能asp代碼》,本文關(guān)鍵詞  適合,所有,網(wǎng),站的,rss,和,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《適合所有網(wǎng)站的rss和xml聚合功能asp代碼》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于適合所有網(wǎng)站的rss和xml聚合功能asp代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章