Search code examples
pythongoogle-app-enginefeedparserpython-2.5

Using feedparser with Google App Engine


I am trying to parse an RSS feed with feedparser. The below code snipped is cut-short for brevity

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.

works fine on my python interpreter but when I add my application to gapp engine launcher and try to run it via localhost:10000 it gives me the following error

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

feedparser module is already installed on my system.

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

I read some articles on stackoveflow and blogs that feedparser doesn't work directly on gapp engine. I followed the advice and used urlfetch.fetch(feed_url) but than also I am getting an error.

PS: PythonPath on gapp launcher is C:\Python25\python.exe


Solution

  • You have feedparser installed locally, so when you run your application on development server it works. But in order to use feedparser on production you need to include it in your project, because GAE do not provide this library for you.

    You need to upload feedparser along with your project files. For this you can copy it into your application root directory and then deploy your application.