osu.py 文件源码

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

项目:Bonfire 作者: Phxntxm 项目源码 文件源码
def _request(self, payload, endpoint):
        """Handles requesting to the API"""

        # Format the URL we'll need based on the base_url, and the endpoint we want to hit
        url = "{}{}".format(base_url, endpoint)

        # Check if our key was added, if it wasn't, add it
        key = payload.get('k', self.key)
        payload['k'] = key

        # Attempt to connect up to our max retries
        for x in range(MAX_RETRIES):
            try:
                async with aiohttp.get(url, headers=self.headers, params=payload) as r:
                    # If we failed to connect, attempt again
                    if r.status != 200:
                        continue

                    data = await r.json()
                    return data
            # If any error happened when making the request, attempt again
            except:
                continue
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号