【问题标题】:Using feedparser with Google App Engine将 feedparser 与 Google App Engine 结合使用
【发布时间】:2012-02-20 09:43:37
【问题描述】:

我正在尝试使用 feedparser 解析 RSS 提要。为简洁起见,以下代码被截断

from google.appengine.api import urlfetch
import feedparser
print 'Content-Type: text/plain'

feed_url = 'http://parsethisurl'
feedinput = urlfetch.fetch(feed_url)

rss_parsed = feedparser.parse(feedinput.content)
......
#some logic here
.........

print "\n".join(episode_info) # printing out the desired output.

在我的 python 解释器上运行良好,但是当我将应用程序添加到 gapp 引擎启动器并尝试通过 localhost:10000 运行它时,它给了我以下错误

<type 'exceptions.ImportError'>: No module named feedparser 
      args = ('No module named feedparser',) 
      message = 'No module named feedparser'

feedparser 模块已经安装在我的系统上。

>>> sys.version
'2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]'
>>> import feedparser
>>>

我阅读了一些关于 stackoveflow 的文章和 feedparser 不能直接在 gapp 引擎上工作的博客。我听从了建议并使用了urlfetch.fetch(feed_url),但我也遇到了错误。

PS:gapp 启动器上的 PythonPath 是 C:\Python25\python.exe

【问题讨论】:

    标签: python google-app-engine feedparser python-2.5


    【解决方案1】:

    您已在本地安装了feedparser,因此当您在开发服务器上运行您的应用程序时,它可以工作。但是为了在生产环境中使用feedparser,您需要将它包含在您的项目中,因为 GAE 不为您提供这个库。

    您需要上传feedparser 以及您的项目文件。为此,您可以将其复制到您的应用程序根目录中,然后部署您的应用程序。

    【讨论】:

      猜你喜欢
      • 2015-10-24
      • 1970-01-01
      • 2020-04-29
      • 2020-05-26
      • 2014-08-26
      • 2014-03-29
      • 2012-02-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多