Python Forum
Find today's RSS entries with feedparser
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find today's RSS entries with feedparser
#2
(Jun-11-2019, 11:40 PM)Biks Wrote: It seems I could just findAll <datepub> tags with BeautifulSoup and match it today's date
You could to that.
Now will task work fine from feedparser to.
If just set a range() to number like eg 10 and loop.
>>> for n in range(10):
...     dgtw['entries'][n]['published']
...     
'Tue, 11 Jun 2019 16:07:41 GMT'
'Tue, 11 Jun 2019 15:03:52 GMT'
'Tue, 11 Jun 2019 14:43:21 GMT'
'Tue, 11 Jun 2019 13:58:31 GMT'
'Tue, 11 Jun 2019 12:24:25 GMT'
'Tue, 11 Jun 2019 03:13:45 GMT'
'Mon, 10 Jun 2019 21:56:47 GMT'
'Mon, 10 Jun 2019 19:58:24 GMT'
'Mon, 10 Jun 2019 19:38:59 GMT'
'Mon, 10 Jun 2019 14:07:38 GMT'
So see that there is 6 entries today.
Then can just do a quick hack.
>>> from datetime import datetime
>>> 
>>> today = datetime.today().day
>>> today
12
>>> today_match =  f', {today}'
>>> today_match
', 12'
when have ', 12' can just use in to look if there is a match in published date string.
>>> today_match =  ', 11'
>>> count = 0
>>> for n in range(10):
...     p_date = dgtw['entries'][n]['published']     
...     if today_match in p_date:
...         count += 1       
...         
>>> count
6
Reply


Messages In This Thread
Find today's RSS entries with feedparser - by Biks - Jun-11-2019, 11:40 PM
RE: Find today's RSS entries with feedparser - by snippsat - Jun-12-2019, 05:36 AM

Forum Jump:

User Panel Messages

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