This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Chris

By: a guest on Apr 18th, 2010  |  syntax: Python  |  size: 0.84 KB  |  views: 162  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.')
clone this paste RAW Paste Data