reddit_scraper.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:main_bot 作者: PythonBuddies 项目源码 文件源码
def get(self, ctx: commands.Context, subreddit, num_posts=5, category='hot'):
        """Base command for returning data from a subreddit.

        Keyword arguments:
        posts -- Number of posts to return (default 5)
        category -- Category to look at [hot, new, rising, controversial, top] (default hot)
        """
        if num_posts > 25:
            await self.bot.say('Number of posts must be no greater than 25.')
            return
        if subreddit.strip():
            if category in self.categories:
                result = await self.get_subreddit_top(
                    session=self.session, subreddit=subreddit, num_posts=num_posts, category=category)
                await self.bot.say('\n\n'.join(result))
            else:
                await self.bot.say('Valid categories are {}: '.format(', '.join(self.categories)))
        else:
            await self.bot.pm_help(ctx)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号