首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用feedparser访问注释

使用feedparser访问注释
EN

Stack Overflow用户
提问于 2012-05-21 11:56:08
回答 1查看 168关注 0票数 0

我有一个Google应用程序引擎应用程序,我正在尝试使用feedparser来访问提要上的评论。我正在使用Google blogger示例中的提要进行测试

代码语言:javascript
复制
<?xml version='1.0' encoding='utf-8'?>
<?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?>
<feed xmlns='http://www.w3.org/2005/Atom'
   xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/'
   xmlns:gd='http://schemas.google.com/g/2005'
   gd:etag='W/"CUYMQ348fyp7ImA9WB9UFkU."'>
  <id>tag:blogger.com,1999:blog-blogID.postpostID..comments</id>
  <updated>2007-12-14T17:46:22.077-08:00</updated>
  <title>Comments on Lizzy's Diary: Quite disagreeable</title>
  <entry gd:etag='W/"CUYCQX47eSp7ImA9WB9UFkU."'>
     <id>tag:blogger.com,1999:blog-blogID.post-commentID</id>
     <published>2007-12-14T17:46:00.001-08:00</published>
     <thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' 
        href='http://blogName.blogspot.com/2007/12/quite-disagreeable_5283.html'
        ref='tag:blogger.com,1999:blog-blogID.post-postID'
        source='http://www.blogger.com/feeds/blogID/posts/default/postID'
        type='text/html' />
  </entry>

目前,我的代码有

代码语言:javascript
复制
d= feedparser.parse(feedurl)
for child in d.entries:
   _url = child.thr_in-reply-to.href

我收到错误消息

代码语言:javascript
复制
raise AttributeError, &quot;object has no attribute '%s'&quot; % key
AttributeError: object has no attribute 'thr_in'

如何访问注释及其任何属性?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-21 22:33:13

它看起来像是点符号,即child.thr_in-reply-to.href不适用于其他名称空间。当我将其更改为

代码语言:javascript
复制
child['thr_in-reply-to']['href']

啊,真灵。

但是,点符号仍然适用于atom名称空间,即访问条目的id,我仍然能够这样做

代码语言:javascript
复制
child.id
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10679345

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档