RSS generated by Asp _ add RSS page 1/2 to the website

Source: Internet
Author: User

What is RSS?
RSS is a simple way for websites to share content with other sites (also called aggregate content). It is usually used for news and other websites in order, such as blogs. A project may contain all the news. Or, it's just additional content or a brief introduction. Links to these projects can usually be linked to all content. Network users can read the content of the website that supports RSS output without opening the website content page by using RSS-supported news aggregation software (such as FeedDemon, SharpReader, and NewzCrawler) on the client. The website provides RSS output to help users discover updates to website content.

How does RSS work?
First, you generally need to download and install an RSS news reader, and then subscribe to the content of news topics you are interested in from the list of aggregated news directories provided by the website. After the subscription, you will obtain the latest content from the subscribed news channel in a timely manner.

What are the characteristics of RSS news?
1. There is no advertisement or picture to influence reading the title or article summary.
2. the RSS reader automatically updates the content of your custom website to ensure timely news.
3. You can add custom RSS feeds to collect news from multiple sources and integrate them into a single data stream.

With the popularization of the Internet, more and more people are used to obtaining and querying information through the Internet. Although a variety of portal websites are emerging, it is indeed very troublesome to move back and forth between websites. The search engine can help us find anything we want, however, searching is also troublesome. Now there is a new way of information on the Internet. He can send all the information we have subscribed to our desktop, not only to learn the latest news in time, in addition, it eliminates the need for annoying online advertisements when Browsing websites. This latest information method is called Information aggregation (RSS.
Through RSS technology, we can receive the latest subscribed information on the desktop of a computer. It is the best way to use RSS reader to receive RSS information. When the content of the website is updated, the RSS reader automatically receives the latest information to the desktop of the local computer, and displays the title and abstract of the latest information, click the title to view the full text. Since the rise of domestic "blogs" last year, RSS resources have gradually increased, and major websites have also launched RSS services. Generally, as long as you see the XML mark on the website, the website provides the RSS service.
FeedDemon, Tencent Internet Information browser, Sina diantong reader, and Zhou botong are common RSS readers.

Copy codeThe Code is as follows: <%
Dim Rs, Newrss
Class Rss
****************** **
'*************************************** ********
'Setconn: the Connection object used by the website.
'Setsql is a required SQL query statement. We strongly recommend that you use Top keywords in SQL statements.
'SQL statement field [News Id, title, content, time, Static Page name]
'Note: do not reverse the order
'If the news is not a generated static page, there is no last item, and the value of SetPageType is 1
'Setwebname: the website name is required.
'Setweburl: the website address is required.
'Setwebdes: the website description is not required.
'Setpagetype mandatory information display Page Link Type 1 is dynamic page Id 0 is static page
'Setmaxinfo is not required. The number of mandatory information displayed is displayed. If the data is obtained> SetMaxInfo, The SetMaxInfo data is displayed. We strongly recommend that you use Top keywords in SQL statements.
'Setcontentshow is optional. Note: this parameter is an array (ShowContentType, ShowContentLen)
'Showcontenttype [numeric type] is the content display mode [parameter (0, 1) 0 is the percentage, even if the display information is displayed, 1 is the word count]
The length of 'showcontentlen content display is determined by ShowContentType.
********************
'Showrss display Rss
'================================================ ====================
'Example
'Set NewRss = New Rss
'Set NewRss. SetConn = article_conn
'Newrss. SetSql = "select top 30 newsid, title, content, dateandtime, N_fname from article where typeid = 1 order by newsid Desc"
'Newrss. SetWebName = "under test"
'Newrss. SetWebUrl = "http://www.jb51.net"
'Newrss. SetMaxInfo = 10
'Newrss. SetInfourl = "http://www.jb51.net"
'Newrss. SetPageType = "0"
& Apos; NewRss. setContentShow = "1,200"
'Newrss. ShowRss ()
'Set NewRss = Nothing
'================================================ ====================
Private Conn, SQL, WebName, WebUrl, WebDes, Er, MaxInfo, I, Infourl, PageType
Private ShowContentType, ShowContentLen
Private AllContent, AllContentLen
Private Sub Class_initialize ()
MaxInfo = 20
'Pagetype = 1
ShowContentType = 0
ShowContentLen = 20
Er = false
End Sub
Private Sub Class_terminate ()
If isObject (Rs) then Set Rs = Nothing
End Sub
Public Property Let Errmsg (msg)
If Er then
Response. Clear ()
Response. Write (msg)
Response. End ()
End If
End Property
Public Property Let SetWebName (WebName _)
WebName = WebName _
End Property
Public Property Let SetWebUrl (WebUrl _)
WebUrl = WebUrl _
End Property
Public Property Let SetWebDes (webDes _)
WebDes = WebDes _
End Property
Public Property Let SetInfoUrl (Infourl _)
Infourl = Infourl _
End Property
Public Property Let SetPageType (PageType _)
PageType = PageType _
End Property
Public Property Let SetMaxInfo (MaxInfo _)
MaxInfo = MaxInfo _
End Property
Public Property Let setContentShow (ContentShow _)
Dim ArrContentShow
ArrContentShow = Split (ContentShow _,",")
If Ubound (ArrContentShow) <> 1 Then Er = True: Errmsg = "the information display parameter settings are incorrect !! "
ShowContentType = ArrContentShow (0)
ShowContentLen = ArrContentShow (1)
If Not isnumeric (ShowContentType) or ShowContentType = "" Then ShowContentType = 0
If Not isnumeric (ShowContentLen) or ShowContentLen = "" Then
If ShowContentType = 0 Then ShowContentLen = 20 Else showcontentlen= 200
Else
If ShowContentType = 0 and (ShowContentLen> 100 or ShowContentLen <10) Then ShowContentLen = 20
End If
End Property
Public Property Set SetConn (Conn _)
If TypeName (Conn _) = "Connection" Then
Set Conn = Conn _
Else
Er = true
Errmsg = "database connection error"
Exit property
End If
End Property
Public Property Let SetSql (SQL _)
SQL = SQL _
End Property
Public Property Get RssHead ()
RssHead = "<? Xml version = "" 1.0 "" encoding = "" gb2312 ""?> "
RssHead = RssHead & "<rss>"
RssHead = RssHead & "<channel>"
RssHead = RssHead & "<title>" & WebName & "</title>"
RssHead = RssHead & "<link>" & WebUrl & "</link>"
RssHead = RssHead & "<description>" & WebDes & "</description>"
End Property
Private Property Get RssBottom ()
RssBottom = "</channel>"
RssBottom = RssBottom & "</rss>"
End Property
Public Sub ShowRss ()
On Error resume Next
Dim Rs
Dim ShowInfoUrl, ShowContent, Content
If TypeName (Conn) <> "Connection" Then Er = True: Errmsg = "Connection object error"
If SQL = "" or isnull (SQL) = "" or isempty (SQL) = "" Then Er = True: Errmsg = "No executable SQL statement"
If WebName = "" or isnull (WebName) = "" or isempty (WebName) = "" Then Er = True: Errmsg = "set the RSS title"
If WebUrl = "" or isnull (WebUrl) = "" or isempty (WebUrl) = "" Then Er = True: Errmsg = "set the link of the Website"
If InfoUrl = "" or isnull (InfoUrl) = "" or isempty (InfoUrl) = "" Then Er = True: Errmsg = "set link information"
If PageType = "" or isnull (PageType) = "" or isempty (PageType) = "" Then Er = True: Errmsg = "set the link type"
Set Rs = Server. CreateObject ("ADODB. RecordSet ")
Rs. Open SQL, Conn, 1, 1
If Err Then
Er = true
Errmsg = "the database cannot be opened <br/> Please check whether your SQL statement is correct"
Exit Sub
End If

Response. Charset = "gb2312"
Response. ContentType = "text/xml"
Response. Write (RssHead)
For I = 1 to MaxInfo
'*****************************
ShowInfoUrl = InfoUrl
If ShowInfoUrl = "" or isnull (ShowInfoUrl) or isempty (ShowInfoUrl) Then
ShowInfoUrl = "#"
Else
If PageType Then ShowInfoUrl = ShowInfoUrl & Rs (0) Else ShowInfoUrl = ShowInfoUrl & Rs (4)
End If
'*****************************
AllContent = LoseHtml (Rs (2 ))
AllContentLen = byteLen (AllContent)
ShowContent = int (ShowContentLen)
If ShowContentType = 0 Then ShowContent = AllContentLen * ShowContent/100
Content = Server. HTMLEncode (titleb (AllContent, ShowContent ))
Response. Write ("<item> ")
Response. Write ("<title> ")
Response. Write (Rs (1 ))
Response. Write ("</title> ")
Response. Write ("<link> ")
Response. Write (ShowInfoUrl)
Response. Write ("</link> ")
Response. Write ("<description> ")
Response. Write (Content)
Response. Write ("</description> ")
Response. Write ("<pubDate> ")
Response. Write (return_RFC822_Date (Rs (3), "GMT "))
Response. Write ("</pubDate> ")
Response. Write ("</item> ")
If Rs. Eof or I> cint (MaxInfo) Then Exit
Rs. MoveNext
Next
Response. Write (RssBottom)
End Sub
Function LoseHtml (ContentStr)
Dim ClsTempLoseStr, regEx
ClsTempLoseStr = Cstr (ContentStr)
Set regEx = New RegExp
RegEx. Pattern = "<\/* [^ <>] *>"
RegEx. IgnoreCase = True
RegEx. Global = True
ClsTempLoseStr = regEx. Replace (ClsTempLoseStr ,"")
LoseHtml = ClsTempLoseStr
End function
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
Function titleb (str, strlen)
Dim Bstrlen
Bstrlen = strlen
If isempty (str) or isnull (str) or str = "" Then
Titleb = str
Exit function
Else
Dim l, t, c, I
L = len (str)
T = 0

For I = 1 to l
C = Abs (Asc (Mid (str, I, 1 )))
If c & gt; 255 then
T = t + 2
Else
T = t + 1
End if

If t> = bstrlen then
Titleb = left (str, I)
Exit
Else
Titleb = str &""
End if
Next
End If
End function
Function byteLen (str)
Dim lenStr, lenTemp, I
LenStr = 0
LenTemp = len (str)
Dim strTemp
For I = 1 to lenTemp
StrTemp = asc (mid (str, I, 1 ))
If strTemp> 255 or strTemp <= 0 then
LenStr = lenStr + 2
Else
LenStr = lenStr + 1
End if
Next
ByteLen = lenStr
End function
End Class
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.