Exemplo n.º 1
0
        def parsed_post(posts):
            for post in posts:
                article = post.get('content') or ''
                comments = post.get('comments') or []

                imgs = self.parse_images(article) + flatten_lists([
                    self.parse_images(cmt.get('content', ''))
                    for cmt in comments
                ])

                if len(imgs):
                    yield post, imgs
Exemplo n.º 2
0
        def parsed_post(posts):
            for post in posts:
                article = post.get('content') or ''
                comments = post.get('comments') or []

                imgs = self.parse_images(article) + flatten_lists([
                    self.parse_images(cmt.get('content', ''))
                    for cmt in comments
                ])

                if len(imgs):
                    yield post, imgs
Exemplo n.º 3
0
    def get_metas(
            self, num=30, sort='new', before=None, timebound=None,
            callback=None):
        logger.info('<%s> 開始取得看板內文章資訊', self.name)

        paged_metas = self.api.get_metas(
            self.name, sort, num, before, timebound)

        buff = flatten_lists(metas for metas in paged_metas)
        results = callback(buff) if callback else buff

        logger.info('<%s> 資訊蒐集完成,共%d筆', self.name, len(buff))
        return results
Exemplo n.º 4
0
 def extract_comments(self, comments):
     return flatten_lists([cs.json() for cs in api.imap(comments)]) \
         if not self.only_id and comments else comments