Example #1
0
 def login(self):
     self._init()
     captcha = Captcha("normal")
     status, msg = captcha.verify()
     if not status:
         Log.v("验证码校验失败")
         return status, msg
     payload = {
         'username': Config.train_account.user,
         'password': Config.train_account.pwd,
         'appid': 'otn',
         'answer': captcha.results
     }
     json_response = send_requests(LOGIN_SESSION,
                                   self.URLS['login'],
                                   data=payload)
     result, msg = json_status(json_response, [], '0')
     if not result:
         return False, msg
     self._passportredirect()
     result, msg, apptk = self._uamtk()
     if not result:
         Log.v(msg)
         return False, msg
     status, msg = self._uamauthclient(apptk)
     return status, msg
Example #2
0
 def check(self, results):
     params_data = {'answer': results, 'rand': 'sjrand', 'login_site': 'E'}
     json_response = send_captcha_requests(
         LOGIN_SESSION,
         LOGIN_URL_MAPPING["normal"]["captchaCheck"],
         params=params_data)
     Log.d('验证码校验结果: %s' % json_response)
     return json_status(json_response, [], ok_code=self.success_code)
Example #3
0
 def _uamtk(self):
     json_data = send_requests(LOGIN_SESSION, self.URLS["uamtk"], data={'appid': 'otn'})
     Log.d(json_data)
     result, msg = json_status(json_data, ["result_message", "newapptk"])
     if not result:
         return result, msg, None
     else:
         return result, msg, json_data["newapptk"]
Example #4
0
 def check(self, results):
     params_data = {'answer': results, 'rand': 'sjrand', 'login_site': 'E'}
     while True:
         try:
             json_response = send_captcha_requests(
                 LOGIN_SESSION,
                 LOGIN_URL_MAPPING["normal"]["captchaCheck"],
                 params=params_data)
             break
         except (ResponseCodeError, ResponseError):
             Log.v("提交验证码错误, 重新提交验证码验证")
             continue
     Log.v('验证码校验结果: %s' % json_response)
     status, msg = json_status(json_response, [], ok_code=self.success_code)
     if not status:
         Log.v("验证码识别失败")
     return status, msg
Example #5
0
 def _uamauthclient(self, apptk):
     json_response = send_requests(LOGIN_SESSION,
                                   self.URLS['uamauthclient'],
                                   data={'tk': apptk})
     return json_status(json_response, ["username", "result_message"])
Example #6
0
 def _uamauthclient(self, apptk):
     json_response = send_requests(LOGIN_SESSION, self.URLS['uamauthclient'], data={'tk': apptk})
     status, msg = json_status(json_response, ["username", "result_message"])
     if status:
         Log.v("欢迎 {0} 登录".format(json_response["username"]))
     return status, msg