0

I am trying to fetch some RSS feeds from a list of blog sites.But, most of these sites have older Feeds entries. And some of these sites do not have any etag information.so i cant check the latest published feed with etag.

I figured out a logic to check the feed according to their published date..But, it is not working.It will be appreciable, if anyone can re-write my code.

import feedparser
import time
from datetime import datetime ,timedelta

today = date.today()

with open("/home/list.txt","r") as f:

    for line in f:
        print line;
        feed_url = line
        feed_list = feedparser.parse(feed_url)
        feed_count = len(feed_list['entries'])
        for item in feed_list.entries:

                if item.feed_list.published == today:

        print item.title + " : " + item.link
Kxplorer
  • 28
  • 8
  • Show error message. Show `list.txt`. Use `print()` to see values in variables. – furas Aug 30 '16 at 13:44
  • Thanks for comments. actually code is working fine... its printing all the feeds from RSS link.Just,it's parsing all feeds in these links.ie. below.code has no impact as these sites do not have any etag info.and I need to parse only latest feed. " if item.feed_list.published == today: " – Kxplorer Aug 30 '16 at 14:18
  • 1
    I put suggestions on FB in LearnPython group as Bartłomiej Burek. – furas Aug 30 '16 at 15:06
  • This was the suggestions shared by @furas. >>> import datetime >>> today = datetime.date.today() >>> print(today) 2016-08-30 >>> today == '2016-08-30' False >>> print(today.strftime('%Y-%m-%d')) 2016-08-30 >> today.strftime('%Y-%m-%d') == '2016-08-30' – Kxplorer Aug 31 '16 at 17:06

0 Answers0