isitdown.py 文件源码

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

项目:beatrice-witchcogs 作者: PookaMustard 项目源码 文件源码
def isitdown(self, url):
        """Checks if a website is down or up."""
        if url == "":
            await self.bot.say("You haven't entered a website to check.")
            return
        if "http://" not in url or "https://" not in url:
            url = "http://" + url
        try:
            with aiohttp.Timeout(15):
                await self.bot.say("Testing " + url + "…")
                try:
                    response = await aiohttp.get(url, headers = { 'user_agent': headers })
                    if response.status == 200:
                        await self.bot.say(url + " is up and running.")
                    else:
                        await self.bot.say(url + " is down.")
                except:
                    await self.bot.say(url + " is down.")
        except asyncio.TimeoutError:
            await self.bot.say(url + " is down.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号