Пример #1
0
 def addFeed(self, url, d, get_full_article):
     url_link = d.feed.link
     feed_key = ndb.Key(url_link, url)
     new_feed = RSSinfo(title = d.feed.title,
                        description = d.feed.description,
                        link = d.feed.link,
                        updated = d.feed.updated,
                        updated_parsed = mktime(d.feed.updated_parsed),
                        published = d.feed.published,
                        published_parsed = mktime(d.feed.published_parsed),
                        url = url,
                        get_full_article = get_full_article,
                        parent = feed_key) 
     new_feed.put()
     self.Initial_feed_item(feed_key)
Пример #2
0
 def get(self):
     
     feeds = RSSinfo.query().fetch()
     item_count = []
     for feed in feeds:
         qty = RSS.query(ancestor = ndb.Key(feed.link, feed.url)).count()
         item_count.append(qty)
     # logging.error(item_count)
     iter_list = range(len(feeds))
     self.render('/index.html', feeds = feeds, item_count = item_count, iter_list = iter_list)
Пример #3
0
 def Initial_feed_item(self, feed_key):
     feed = RSSinfo.query(ancestor = feed_key).get()
     d = feedparser.parse(feed.url)
     item_key = feed.key
     num = len(d.entries)
     for i in range(num):
         c = d.entries[i]
         self.sanitize_item(c, item_key)
         self.addItem(c, item_key)
     self.redirect('/')
Пример #4
0
 def get(self):
     client = ParserClient(token='64c0f2ae58811bc3d09104e8d22abb3e3b328971')
     feeds = RSSinfo.query()
     for feed in feeds:
         if feed.get_full_article == True:
             items = RSS.query(ancestor = feed.key)
             for item in items:
                 if item.content == 'no content':
                     parser_response = client.get_article(url = item.link)
                     sleep(1)
                     article = parser_response.json()
                     item.content = article['content']
                     item.put()
                 else:
                     pass
         else:
             pass
Пример #5
0
 def get(self):
     feeds = RSSinfo.query()
     for feed in feeds:
         item_key = feed.key
         last_item = RSS.query(ancestor = item_key).order(-RSS.published_parsed).get()
         d = feedparser.parse(feed.url)
         num = len(d.entries)
         for i in range(num):
             c = d.entries[i]
             if last_item == None:
                 self.sanitize_item(c, item_key)
                 self.addItem(c, item_key)
             else:
                 self.sanitize_item(c, item_key)
                 if mktime(c.published_parsed) > last_item.published_parsed:
                     self.addItem(c, item_key)
                 else:
                     pass
     self.response.set_status(204)