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 A开发者_如何学Ctom doc as XML?
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.
精彩评论