2012-02-20 56 views
2

我在尝试使用feedparser解析RSS提要。剪断下面的代码被切断短为简洁在Google App Engine中使用feedparser

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解释器,但是当我在我的应用程序添加到新闻出版总署引擎启动,并尝试通过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不对新闻出版总署引擎直接工作。我遵循了建议并使用了urlfetch.fetch(feed_url),但同时我也遇到了错误。

PS:在国家新闻出版总署发射PYTHONPATH是C:\Python25\python.exe

回答

5

feedparser本地安装的,所以当你运行它的工作原理开发服务器上的应用程序。但为了在生产中使用feedparser,您需要将其包含在您的项目中,因为GAE不会为您提供此库。

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

+0

谢谢,它的工作。 – Noob 2012-02-20 19:04:05