aiosteamsearch.py 文件源码

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

项目:steamsearch 作者: billy-yoyo 项目源码 文件源码
def get_user(steamid, timeout=10, be_specific=False):
    """Gets some information about a specific steamid

    Args:
        steamid (str): The user's steamid
        timeout (int, optional): The amount of time before aiohttp raises a timeout error
    Returns:
        a UserResult object
        """
    if not is_integer(steamid):
        steamid = yield from search_for_userid(steamid, be_specific=be_specific)
    if steamid is not None:
        _check_key_set()
        with aiohttp.ClientSession() as session:
            with aiohttp.Timeout(timeout):
                resp = yield from session.get("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" + STEAM_KEY + "&steamids=" + steamid)
                data = yield from resp.json()

                if "response" in data and "players" in data["response"] and len(data["response"]["players"]) > 0:
                    player = data["response"]["players"][0]
                    return UserResult(player)
    return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号