client.py 文件源码

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

项目:Pyanimelist 作者: GetRektByMe 项目源码 文件源码
def get_user_series(self, username: str, series_type: str):
        """
        :param username: The name of the accounts information you're trying to get
        :param series_type: If you're looking for manga or anime
        :return type list:
        """
        params = {
            "u": username,
            "status": 'all',
            "type": series_type
        }
        if series_type not in ("anime", "manga"):
            raise InvalidSeriesTypeException
        else:
            with aiohttp.ClientSession(auth=self._auth, headers={"User-Agent": self.user_agent}) as session:
                async with session.get(MAL_APP_INFO, params=params) as response:
                    # Raise an error if we get the wrong response code
                    if response.status != 200:
                        raise ResponseError(response.status)
                    # Get the response text and set parser
                    soup = bs4.BeautifulSoup(await response.text(), "lxml")
                    return [dict(self.process_(child) for child in anime.children) for anime in soup.find_all(series_type)]
    # End of bit Zeta wrote
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号