api.py 文件源码

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

项目:pyTBA 作者: Thing342 项目源码 文件源码
def tba_get(self, path):
        """Base method for querying the TBA API. Returns the response JSON as a python dict.
        :param path: (str) Request path, without the API address prefix (https://www.thebluealliance.com/api/v2/)
        :return: A dict parsed from the response from the API.
        """

        if self.app_id['X-TBA-App-Id'] == "":
            raise Exception('An API key is required for TBA. Please use set_api_key() to set one.')

        url_str = 'https://www.thebluealliance.com/api/v2/' + path
        r = self.session.get(url_str, headers=self.app_id)
        # print(r.url)
        tba_txt = r.text
        try:
            return json.loads(tba_txt)
        except json.JSONDecodeError:
            print(url_str)
            print(tba_txt)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号