kurtmckee/feedparser

How to add namespaces?

Closed this issue · 2 comments

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!

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.

Excellent! Thanks for the followup!