animelist.py 文件源码

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

项目:Jumper-Cogs 作者: Redjumpman 项目源码 文件源码
def fetch_user_mal(self, name, url, cmd):
        with aiohttp.ClientSession() as session:
            async with session.get(url.format(name)) as response:
                data = await response.text()
                try:
                    root = ET.fromstring(data)

                except ET.ParseError:
                    return '', ''

                else:
                    if len(root) == 0:
                        return '', ''

                    collection = {x.find('series_title').text for x in root.findall(cmd)}
                    entry = root.find('myinfo')
                    if cmd == "anime":
                        info = [entry.find(x).text for x in ['user_watching', 'user_completed',
                                                             'user_onhold', 'user_dropped',
                                                             'user_days_spent_watching']]
                        return collection, info
                    else:
                        info = [entry.find(x).text for x in ['user_reading', 'user_completed',
                                                             'user_onhold', 'user_dropped',
                                                             'user_days_spent_watching']]
                        return collection, info
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号