Internet.py 文件源码

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

项目:Sparcli 作者: 4Kaylum 项目源码 文件源码
def pun(self, ctx):
        '''
        Gives a random pun from the depths of the internet
        '''

        # Read from page
        async with self.session.get('http://www.punoftheday.com/cgi-bin/randompun.pl') as r:
            page = await r.text()

        # Scrape the raw HTML
        r = r'(<div class=\"dropshadow1\">\n<p>).*(</p>\n</div>)'
        foundPun = [i for i in finditer(r, page)][0].group()

        # Filter out the pun
        r = r'(>).*(<)'
        filteredPun = [i for i in finditer(r, foundPun)][0].group()

        # Boop it out
        fullPun = filteredPun[1:-1]
        await self.sparcli.say(fullPun)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号