kurtmckee / feedparser

Parse feeds in Python
https://feedparser.readthedocs.io
Other
1.99k stars 343 forks source link

feedparser cannot parse multiple "category" value? #40

Open t2y opened 9 years ago

t2y commented 9 years ago

According to RSS 2.0 Specification, category item may include multiple values.

You may include as many category elements as you need to, for different domains, and to have an item cross-referenced in different parts of the same domain.

There's a sample including multiple category values as below.

>>> import feedparser
>>> feedparser.__version__
'5.2.1'
>>> data = feedparser.parse('http://www.validome.org/check/RSS_validator/version/rss_2_0/action/xml/feed/234')
>>> data.feed.get('category')
u'category/subcategory/subcategory2'

Is this a bug?

t2y commented 9 years ago

I found tags handles multiple category values. We have a workaround.

>>> data.feed.get('tags')
[{'label': None,
  'scheme': u'http://www.validome.org/cat1/',
  'term': u'category/subcategory/subcategory2'},
 {'label': None,
  'scheme': u'http://www.validome.org/cat2',
  'term': u'category/subcategory/subcategory3'}]