我使用SSH通过SSH安装了feedparser
$ python setup.py install --home=~/httpdocs/python-libraries/feedparser-4.1/
我这样做是因为我似乎没有权限正确运行'python setup.py install'
我在'test.py'中运行以下python代码.
print "Content-type: text/html\n\n"
try:
    import feedparser
except:
    print "Cannot import feedparser.\n"
我通过SSH登录时代码运行正常.但是当我在浏览器中查看它时,它会打印出来
Cannot import feedparser.
有任何想法吗?
试图在这里绕过Feedzirra.
我拥有所有设置和所有内容,甚至可以获得结果和更新,但奇怪的事情正在发生.
我想出了以下代码:
  def initialize(feed_url)
    @feed_url = feed_url
    @rssObject =  Feedzirra::Feed.fetch_and_parse(@feed_url)
  end
  def update_from_feed_continuously()    
    @rssObject = Feedzirra::Feed.update(@rssObject)
    if @rssObject.updated?
      puts @rssObject.new_entries.count
    else
      puts "nil"
    end
  end
是的,我上面做的是从大饲料开始,然后只获得更新.我确定我必须做一些愚蠢的事情,因为即使我能够获得更新,并将它们存储在同一个实例变量上,在第一次之后,我再也无法获得这些更新.
显然这是因为我只用更新覆盖了我的实例变量,并且丢失了完整的feed对象.
然后我考虑将我的代码更改为:
  def update_from_feed_continuously()    
    feed = Feedzirra::Feed.update(@rssObject)
    if feed.updated?
      puts feed.new_entries.count
    else
      puts "nil"
    end
  end
好吧,我没有覆盖任何东西,那应该是正确的方法吗?
错误,这意味着我注定总是试图获取相同静态订阅源对象的更新,因为虽然我得到了变量的更新,但我实际上从未更新过我的"静态订阅源对象",而新添加的项目将是附加到我的"feed.new_entries",因为它们在理论上是新的.
我敢肯定,我在这里错过了一步,但如果有人能让我了解它,我真的很感激.我已经经历了几个小时的代码,无法掌握它.
显然它应该工作正常,如果我做了类似的事情:
if feed.updated?
  puts feed.new_entries.count
  @rssObject = initialize(@feed_url)
else
因为这将使用全新的feed对象重新初始化我的实例变量,并且更新将再次出现.
但这也意味着在那个确切的时刻添加的任何新更新都将丢失,以及大量的过度杀伤,因为我必须再次加载该东西.
提前致谢!
当RSS客户端遇到具有相同guid /标识符的多个项目的订阅源时,它应具有的正确响应是什么?
目前在我的应用程序中,任何使用现有guid的项目都不会被缓存或显示,因为它认为它已经拥有该项目.
在此示例Feed中,许多项目共享此ID:
tag:blizzard.com,2010-10-22:diablo3:feed:en-us:1
昨天我安装了feedparser(在OSX 10.5上),它工作正常,但现在它停止工作了.
这是脚本(从feedparser文档复制)
import feedparser
d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml')
d['feed']['title']
u'Sample Feed'
它告诉我这个:
Traceback (most recent call last):
  File "example.py", line 3, in <module>
    import feedparser
  File "example.py", line 2, in <module>
    d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml')
AttributeError: 'module' object has no attribute 'parse'
但是使用feedparser的实际脚本也停止了工作,同样的错误.
如何从此Feed中获取"入口"节点
http://www.google.com/alerts/feeds/14392773026536511983/5526937985735563348
我试过linq到xml,但我认为因为代码后面的条目标签的现有属性不起作用.
string url = "http://www.google.com/alerts/feeds/14392773026536511983/5526937985735563348";
WebClient c = new WebClient();
string xml = ASCIIEncoding.Default.GetString(c.DownloadData(url));
XDocument doc = XDocument.Parse(xml);
var entries = doc.Descendants("entry");
提前致谢,
我正在尝试使用 feedparserpython从 sub_reddit 获取最新的帖子。
我有下面的代码,但当我运行它时它没有返回任何内容。
import feedparser
feed = feedparser.parse("http://www.reddit.com/r/funny/new/.rss")
#feed = feedparser.parse("http://feeds.bbci.co.uk/news/england/london/rss.xml")
feed_entries = feed.entries
for entry in feed.entries:
    article_title = entry.title
    article_link = entry.link
    article_published_at = entry.published # Unicode string
    article_published_at_parsed = entry.published_parsed # Time object
    print (article_title)
在此示例 RSS 提要中,可选项目元素pubDate包含在所有条目中。但它不能作为 Python 模块feedparser 中的 item 元素使用。这段代码:
import feedparser
rss_object = feedparser.parse("http://cyber.law.harvard.edu/rss/examples/rss2sample.xml")
for entry in rss_object.entries:
    print entry.pubDate
导致错误,AttributeError: object has no attribute 'pubDate'但我可以成功执行print entry.description并查看所有描述标签的内容。
feedparser ×7
python ×4
rss ×4
atom-feed ×1
browser ×1
c# ×1
import ×1
linq-to-xml ×1
python-2.7 ×1
rss2 ×1
ruby ×1