horoscope.py 文件源码

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

项目:ax-cogs 作者: Aioxas 项目源码 文件源码
def file_check(self):
        urls = ["https://images-2.discordapp.net/.eJwNwcENwyAMAMBdGABDCWCyDSKIoCYxwuZVdff27qPWvNSuTpHBO8DRudA8NAvN3Kp"
                "uRO2qeXTWhW7IIrmcd32EwQbjMCRMaJNxPmwILxcRg_9Da_yWYoQ3dV5z6fE09f0BC6EjAw.B0sII_QLbL9kJo6Zbb4GuO4MQNw",
                "https://cdn.discordapp.com/attachments/218222973557932032/240223136447070208/FortuneCookieNF.ttf"]
        option = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0)'
                  ' Gecko/20100101 Firefox/40.1'}
        if os.path.exists("data/horoscope/cookie.png"):
            async with aiohttp.request("GET", urls[0], headers=option) as resp:
                test = await resp.read()
                meow = False
                with open("data/horoscope/cookie.png", "rb") as e:
                    if len(test) != len(e.read()):
                        meow = True
                if meow:
                    with open("data/horoscope/cookie.png", "wb") as f:
                        f.write(test)
        elif not os.path.exists("data/horoscope/cookie.png"):
            async with aiohttp.request("GET", urls[0], headers=option) as resp:
                test = await resp.read()
                with open("data/horoscope/cookie.png", "wb") as f:
                    f.write(test)
        if not os.path.exists("data/horoscope/FortuneCookieNF.ttf"):
            async with aiohttp.request("GET", urls[1], headers=option) as resp:
                test = await resp.read()
                with open("data/horoscope/FortuneCookieNF.ttf", "wb") as f:
                    f.write(test)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号