def go_login(self): """ 登陆 :param user: 账户名 :param passwd: 密码 :return: """ if self.is_auto_code and self.auto_code_type == 1: balance = DamatuApi( _get_yaml()["auto_code_account"]["user"], _get_yaml()["auto_code_account"]["pwd"]).getBalance() if int(balance) < 40: raise balanceException(u'余额不足,当前余额为: {}'.format(balance)) user, passwd = _get_yaml()["set"]["12306account"][0][ "user"], _get_yaml()["set"]["12306account"][1]["pwd"] if not user or not passwd: raise UserPasswordException(u"温馨提示: 用户名或者密码为空,请仔细检查") login_num = 0 while True: getPassCodeNewOrderAndLogin(session=self.session, imgType="login") self.randCode = getRandCode(self.is_auto_code, self.auto_code_type) login_num += 1 self.auth() if self.codeCheck(): uamtk = self.baseLogin(user, passwd) if uamtk: self.getUserName(uamtk) break
def go_login_v2(self, user, passwd, rand_code=None): if self.is_auto_code and self.auto_code_type == 1: balance = DamatuApi( _get_yaml()["auto_code_account"]["user"], _get_yaml()["auto_code_account"]["pwd"]).getBalance() if int(balance) < 40: raise balanceException(u'余额不足,当前余额为: {}'.format(balance)) if not user or not passwd: raise UserPasswordException(u"温馨提示: 用户名或者密码为空,请仔细检查") login_num = 0 if rand_code is None: self.randCode = getRandCode(self.is_auto_code, self.auto_code_type) else: self.randCode = rand_code login_num += 1 self.auth() status, mess = self.codeCheck() if status: uamtk, mess = self.baseLogin(user, passwd) if uamtk: st, name = self.getUserName(uamtk) return mess, name else: return mess, ''
def go_login(self): """ 登陆 :param user: 账户名 :param passwd: 密码 :return: """ if self.is_aotu_code and self.aotu_code_type == 1: balance = DamatuApi(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"]).getBalance() if int(balance) < 40: raise balanceException(u'余额不足,当前余额为: {}'.format(balance)) user, passwd = _get_yaml()["set"]["12306count"][0]["uesr"], _get_yaml( )["set"]["12306count"][1]["pwd"] if not user or not passwd: raise UserPasswordException(u"温馨提示: 用户名或者密码为空,请仔细检查") login_num = 0 while True: self.cookietp() self.urlConf["getCodeImg"]["req_url"] = self.urlConf["getCodeImg"][ "req_url"].format(random.random()) self.readImg(self.urlConf["getCodeImg"]) self.randCode = self.getRandCode() login_num += 1 self.auth() if self.codeCheck(): uamtk = self.baseLogin(user, passwd) if uamtk: self.getUserName(uamtk) break
def go_login(self): """ 登陆 :param user: 账户名 :param passwd: 密码 :return: """ if self.is_aotu_code and self.aotu_code_type == 1: balance = DamatuApi(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"]).getBalance() if int(balance) < 40: raise balanceException('余额不足,当前余额为: {}'.format(balance)) user, passwd = _get_yaml()["set"]["12306count"][0]["uesr"], _get_yaml()["set"]["12306count"][1]["pwd"] if not user or not passwd: raise UserPasswordException("温馨提示: 用户名或者密码为空,请仔细检查") login_num = 0 while True: self.cookietp() self.httpClint.set_cookies(_jc_save_wfdc_flag="dc", _jc_save_fromStation="%u4E0A%u6D77%u8679%u6865%2CAOH", _jc_save_toStation="%u5170%u5DDE%u897F%2CLAJ", _jc_save_fromDate="2018-02-14", _jc_save_toDate="2018-01-16", RAIL_DEVICEID="EN_3_EGSe2GWGHXJeCkFQ52kHvNCrNlkz9n1GOqqQ1wR0i98WsD8Gj-a3YHZ-XYKeESWgCiJyyucgSwkFOzVHhHqfpidLPcm2vK9n83uzOPuShO3Pl4lCydAtQu4BdFqz-RVmiduNFixrcrN_Ny43135JiEtqLaI") self.randCode = self.readImg(self.urlConf["getCodeImg"]["req_url"]) login_num += 1 self.auth() if self.codeCheck(): uamtk = self.baseLogin(user, passwd) if uamtk: self.getUserName(uamtk) break
def go_login(self): """ 登陆 :param user: 账户名 :param passwd: 密码 :return: """ if self.is_aotu_code and self.aotu_code_type == 1: balance = DamatuApi(_get_yaml()["damatu"]["uesr"], _get_yaml()["damatu"]["pwd"]).getBalance() if int(balance) < 40: raise balanceException(u'余额不足,当前余额为: {}'.format(balance)) user, passwd = _get_yaml()["set"]["12306count"][0]["uesr"], _get_yaml()["set"]["12306count"][1]["pwd"] if not user or not passwd: raise UserPasswordException(u"温馨提示: 用户名或者密码为空,请仔细检查") login_num = 0 while True: self.cookietp() self.httpClint.set_cookies(_jc_save_showIns="true", _jc_save_wfdc_flag="dc", _jc_save_fromDate=_get_yaml()["set"]["station_dates"][0], _jc_save_toDate=_get_yaml()["set"]["station_dates"][0]) self.urlConf["getCodeImg"]["req_url"] = self.urlConf["getCodeImg"]["req_url"].format(random.random()) self.readImg(self.urlConf["getCodeImg"]) self.randCode = self.getRandCode() login_num += 1 self.auth() if self.codeCheck(): uamtk = self.baseLogin(user, passwd) if uamtk: self.getUserName(uamtk) break
def go_login(self): """ 登陆 :param user: 账户名 :param passwd: 密码 :return: """ if self.is_auto_code and self.auto_code_type == 1: balance = DamatuApi( _get_yaml()["auto_code_account"]["user"], _get_yaml()["auto_code_account"]["pwd"]).getBalance() if int(balance) < 40: raise balanceException(u'余额不足,当前余额为: {}'.format(balance)) user, passwd = _get_yaml()["set"]["12306account"][0][ "user"], _get_yaml()["set"]["12306account"][1]["pwd"] self.user, self.passwd = user, passwd if not user or not passwd: raise UserPasswordException(u"温馨提示: 用户名或者密码为空,请仔细检查") # login_num = 0 while True: if not getPassCodeNewOrderAndLogin(session=self.session, imgType="login"): continue else: # self.check_code() break pub.subscribe(self.check_code, 'rand_code')
def go_login(self): """ 登陆 :param user: 账户名 :param passwd: 密码 :return: """ if self.is_auto_code and self.auto_code_type == 1: balance = DamatuApi(_get_yaml()["auto_code_account"]["user"], _get_yaml()["auto_code_account"]["pwd"]).getBalance() if int(balance) < 40: raise balanceException(u'余额不足,当前余额为: {}'.format(balance)) user, passwd = _get_yaml()["set"]["12306account"][0]["user"], _get_yaml()["set"]["12306account"][1]["pwd"] if not user or not passwd: raise UserPasswordException(u"温馨提示: 用户名或者密码为空,请仔细检查") login_num = 0 while True: result = getPassCodeNewOrderAndLogin(session=self.session, imgType="login") if not result: continue self.randCode = getRandCode(self.is_auto_code, self.auto_code_type, result) login_num += 1 self.auth() if self.codeCheck(): uamtk = self.baseLogin(user, passwd) if uamtk: self.getUserName(uamtk) break # if __name__ == "__main__": # # main() # # logout()
def main(self): balance = self.getBalance() if int(balance) > 40: result = self.decode(287) img_code = result.replace('|', ',') if not isinstance(result, int) else "" return img_code else: raise balanceException('余额不足,当前余额为: {}'.format(balance))