Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving ETag attribute with Feedparser

I know that Feedparser supports retrieval of the ETag header (http://www.feedparser.org/docs/http-etag.html), but the feed I'm retrieving includes 'etag' as an attribute in the content node, for each entry item retrieved:
<content type="application/json" etag="c04bada0055b8a12decd459302b2f777">{"name":"Badiou","parent":false}</content>

When I parse the Atom doc, however, this attribute appears to be thrown away:
'content': [{'base': u'', 'type': u'application/json', 'value': u'{"name":"Badiou","parent":false}', 'language': None}]

Is this a Feedparser limitation, and if so, can anyone suggest a way to retrieve it, or will I just have to parse the Atom doc as XML?

like image 316
urschrei Avatar asked Sep 11 '26 16:09

urschrei


1 Answers

Atom and RSS are standards, and standards are expected to be implemented in a predefined way. Feedparser api lets us to parse ATOM and RSS feeds which are standard compatible. Accordingly the ETag is expected to be sent as a header attribute and not as an attribute of a body element. This is why feedparser is throwing away the non standard etag attribute. This is not a limitation of feedparser, since proper etags can be retrieved as explained in their documentation @ http://packages.python.org/feedparser. So I think you have to parse the atom feed as an XML document.

like image 100
tejzpr Avatar answered Sep 13 '26 07:09

tejzpr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!