kurtmckee/feedparser

Report RSS URL Direct Parsing Issue

bdim404 opened this issue · 3 comments

I have encountered an issue when using the feedparser library to parse RSS directly from a URL. For example:

>>> feedparser.parse('https://hackernewsrss.com/feed.xml').keys()
dict_keys(['bozo', 'entries', 'feed', 'headers', 'bozo_exception'])
>>> d = feedparser.parse('https://hackernewsrss.com/feed.xml')
>>> d['feed']['title']

This results in the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/feedparser/util.py", line 113, in __getitem__
    return dict.__getitem(self, key)
KeyError: 'title'

However, when I download the XML file to my local system and parse it using feedparser's local file reading method, it works correctly, as shown below:

>>> d = feedparser.parse(r'./a.xml')
>>> d['feed']['title']
'Hacker News: New Comments'
>>> d['feed']['links']
[{'rel': 'alternate', 'type': 'text/html', 'href': 'https://news.ycombinator.com/newcomments'}]

I believe this may be a potential bug, as it should be possible to parse content directly from an RSS URL. I would appreciate it if this issue could be addressed. Thank you!