Hi everyone. I'm trying to create an RSS reader with Google Apps Engine, Python and feedparser. As a first step I've tried to print the title of one article to the page.
Regardless of whether I run the program on localhost or appspot.com I get the following error:
AttributeError: 'module' object has no attribute 'parse'
My directory has the following files in it:
- feedparser.pyc
- templates
- - news.html
- main.pyc
- favicon.ico
- feedparser.py
- main.py
- app.yaml
- index.yaml
Here's my main.py code:
import os
import webapp2
import jinja2
import feedparser
template_dir = os.path.join(os.path.dirname(__file__), 'templates')
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir),
autoescape = True)
def render_str(template, **params):
t = jinja_env.get_template(template)
return t.render(params)
class BaseHandler(webapp2.RequestHandler):
def render(self, template, **kw):
self.response.out.write(render_str(template, **kw))
def write(self, *a, **kw):
self.response.out.write(*a, **kw)
class MainPage(BaseHandler):
def get(self):
post = feedparser.parse('http://www.theguardian.com/au/rss').entries[0].title
self.render('news.html', posts = post)
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
I've searched on stackoverflow and elsewhere for solutions and have already tried the following with no luck:
Not sure all of this is relevant but I'm using:
Thanks in advance for your time!
p.s. this is my first time posting to stackoverflow so any tips on etiquette are also welcome.
Hi everyone. I'm trying to create an RSS reader with Google Apps Engine, Python and feedparser. As a first step I've tried to print the title of one article to the page.
Regardless of whether I run the program on localhost or appspot.com I get the following error:
Internal Server Error
The server has either erred or is incapable of performing the requested operation.
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/s~mynews-xxxxx/1.383897364028032608/main.py", line 41, in get
posts = feedparser.parse('http://www.theguardian.com/au/rss').entries[0].title