kurtmckee / feedparser

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

How to add namespaces? #265

Closed MHellmund closed 3 years ago

MHellmund commented 3 years ago

I use feedparser for access to arxiv.org, according to the example in https://arxiv.org/help/api/user-manual#python_simple_example (code example in table 4.2) But in recent versions, this:

# Opensearch metadata such as totalResults, startIndex, 
# and itemsPerPage live in the opensearch namespase.
# Some entry metadata lives in the arXiv namespace.
# This is a hack to expose both of these namespaces in
# feedparser v4.1
feedparser._FeedParserMixin.namespaces['http://a9.com/-/spec/opensearch/1.1/'] = 'opensearch'
feedparser._FeedParserMixin.namespaces['http://arxiv.org/schemas/atom'] = 'arxiv'

no longer works. Is there a workaround? Many thanks!

MHellmund commented 3 years ago

I found a workaround. After changing the two lines above to

feedparser.mixin._FeedParserMixin.namespaces['http://a9.com/-/spec/opensearch/1.1/'] = 'opensearch' feedparser.mixin._FeedParserMixin.namespaces['http://arxiv.org/schemas/atom'] = 'arxiv'

my scripts are working again.

kurtmckee commented 3 years ago

Excellent! Thanks for the followup!