Python Forum
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RSS Feed reader
#1
Hi,
I'm still new to Python and I'm playing around with an RSS reader.
The code actually works so far so I'm very proud of myself Big Grin

The code below reads ONE rss feed and matches it against keywords and based on that it perfoms an action.
The only thing is, it only reads ONE rss feed and I would like to let it read more than ONE feed.

So I thought that I could change:
d = feedparser.parse('https://feed1.rss')
into:
d = feedparser.parse('https://feed1.rss','https://feed2.rss')
But that doesn't seem to work.
What would be the easiest way to achieve this?


Original and full code:
#!/usr/bin/python
import feedparser
import os
import time

# Reset old_message
old_message = ""

# Reset flag
flag = 0

while True:
        # Whipe screen
        os.system('clear')
        # Read RSS Feed
        d = feedparser.parse('https://feed1.rss')

        # Gather title
        title = d['entries'][0]['title']
        # Title to uppercase
        title = title.upper()
        # Gather description
        description = d['entries'][0]['description']
        # Description to uppercase
        description = description.upper()

        # Combine title and description to message
        message = title + " " + description

        # Conditions need to be in capitals
        if message.find("56") != -1:
                 flag = 1

        if message.find("HO") != -1:
                flag = 1

        # If flag = true
        if flag == 1:
                if message != old_message:
                        print("\033[1;31;40m *** ALERT ***")
                        old_message = message

        print title
        print description
        print flag
        flag = 0
        print("\033[1;32;40m")

        time.sleep(10)
Reply


Messages In This Thread
RSS Feed reader - by rfrancocantero - Aug-03-2018, 11:50 AM
RE: RSS Feed reader - by Vysero - Aug-03-2018, 03:52 PM
RE: RSS Feed reader - by rfrancocantero - Aug-03-2018, 05:32 PM
RE: RSS Feed reader - by Vysero - Aug-03-2018, 07:23 PM
RE: RSS Feed reader - by rfrancocantero - Aug-03-2018, 07:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Implementing classes , RSS feed program Miraclefruit 1 3,530 Oct-16-2017, 04:11 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020