Exemplo n.º 1
0
 def get_net_balance(self):
     """
     获取Dr.com的上网费用余额
     :return: float  2.33
     """
     data = {
         'jsondata': '{"query_net_info": {"aid": "%s", "account": "%s", "payacc": ""}}'  # 无法使用format格式化
                     % (AIDS['net'], self._get_inner_account()),
         'funname': 'synjones.onecard.query.net.info',
         'json': True,
     }
     result = self._url2json(url=URL.card_common(), data=data, method='post')
     result = json.loads(result['Msg'])
     return float(re.search(r'余额(\d*\.\d*)元', result['query_net_info']['errmsg']).groups()[0])
Exemplo n.º 2
0
 def _get_build_ids(self, aid):
     """获取建筑的id"""
     data = {
         'jsondata': '{"query_elec_building": {"aid": "%s", "account": "%s", "area": {"area": "", "areaname": ""}}}'
                     % (aid, self._get_inner_account()),
         'funname': 'synjones.onecard.query.elec.building',
         'json': True,
     }
     result = self._url2json(data=data, url=URL.card_common(), method='post')
     result = json.loads(result['Msg'])
     # - -!
     building_id = {}
     for build in result['query_elec_building']['buildingtab']:
         building_id[build['building']] = build['buildingid']
     return building_id