我正在尝试使用 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启动器上的Python路径是C:\Python25\python.exe
最佳答案
您已在本地安装了 feedparser
,因此当您在开发服务器上运行应用程序时,它可以正常工作。但为了在生产中使用 feedparser
,您需要将其包含在您的项目中,因为 GAE 不为您提供此库。
您需要上传 feedparser
以及您的项目文件。为此,您可以将其复制到应用程序根目录中,然后部署您的应用程序。
关于python - 将 feedparser 与 Google App Engine 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9359006/