Exemple #1
0
 def __call__(self):
     req = requests.get(url=self.url, params=self.params, headers=self.headers, cookies=self.cookies, verify=False)
     if req.ok:
         con = json.loads(req.text)
         if con["code"] != 0:
             raise exception.BiliException(con["code"], con["message"])
         else:
             return con["data"]
     else:
         raise exception.NetworkException(req.status_code)
Exemple #2
0
 def __call__(self):
     req = requests.get(url=self.url,
                        params=self.params,
                        headers=self.headers,
                        cookies=self.cookies,
                        verify=False)
     if req.ok:
         con = json.loads(req.text)
         if con["code"] != 0:
             raise exception.BiliException(con["code"], con["message"])
         else:
             #take care of new api
             if 'data' in con.keys():
                 return con['data']
             else:
                 if 'result' in con.keys():
                     return con["result"]
                 else:
                     raise exception.BiliException('data key error', con)
     else:
         raise exception.NetworkException(req.status_code)
Exemple #3
0
 def __call__(self):
     req = requests.post(url=self.url,
                         data=self.data,
                         headers=self.headers,
                         cookies=self.cookies)
     if req.ok:
         con = json.loads(req.text)
         if con["code"] != 0:
             raise exception.BiliException(con["code"], con["message"])
         else:
             return con
     else:
         raise exception.NetworkException(req.status_code)