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
评论列表
文章目录