Advertisement
Guest User

Chris

a guest
Apr 18th, 2010
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. class FeedEntry3(db.Model):
  2.   title = db.StringProperty
  3.   link = db.StringProperty
  4.   content = db.TextProperty
  5.  
  6. class grabFeed(webapp.RequestHandler):
  7.     def get(self):
  8.         result = urlfetch.fetch('http://feeds.feedburner.com/google/CPJ?format=xml')
  9.         if result.status_code == 200:
  10.             feed = feedparser.parse(result.content)
  11.             for entry in feed['entries']:
  12.                 x = FeedEntry3()
  13.                 x.title = unicode(entry['title'])
  14.                 x.link = entry['link']
  15.                 x.content = entry['content'][0].value
  16.                 # this doesn't work - doesn't appear to save values (not showing in datastore viewer)
  17.                 x.put()
  18.                
  19.                 # This seems to work
  20.                 self.response.out.write('<li>Title: %s</li>' % x.title)
  21.                 self.response.out.write('<li>Link: %s</li>' % x.link)
  22.                 self.response.out.write('<li>Content: %s</li>' % x.content)
  23.            
  24.         self.response.out.write('Done.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement