Example #1
0
    def _get_api(self, login_url, exist_verify, **kwargs):
        # 登录请求
        code = ''
        login_types = ['学生', '教师', '部门']
        login_payload = self._get_login_payload(login_url, **kwargs)
        if exist_verify:
            res = self._get('/CheckCode.aspx')
            if res.content[:7] != to_binary('GIF89aH'):
                raise CheckCodeException(self.code, "验证码获取失败")
            code = CHECK_CODE.verify(res.content)

        account = self.user.account.encode('gb2312')
        payload = {
            'txtUserName': account,
            'TextBox1': account,
            'TextBox2': self.user.password,
            'TextBox3': code,
            'txtSecretCode': code,
            'RadioButtonList1':
            login_types[self.user.user_type].encode('gb2312'),
            'Button1': ' 登 录 '.encode('gb2312')
        }
        payload.update(login_payload)

        res = self._post(login_url,
                         data=payload,
                         allow_redirects=False,
                         **kwargs)
        return res
Example #2
0
 def __str__(self):
     _repr = '{msg}'.format(msg=self.errmsg)
     msg = to_binary(_repr) if six.PY2 else to_text(_repr)
     return msg
Example #3
0
 def __repr__(self):
     _repr = 'school_code:{school_code}, Error message: {name},{msg}'.format(
         school_code=self.school_code, name=self.name, msg=self.errmsg)
     msg = to_binary(_repr) if six.PY2 else to_text(_repr)
     return msg