示例#1
0
def get_redirect(name, data, post_url, session):
    logining_page = session.post(post_url, data=data, headers=headers)
    login_loop = logining_page.content.decode("GBK")

    # 登录名或密码错误
    if 'retcode=101' in login_loop:
        login.error(
            'invalid password for {}, please ensure your account and password'.
            format(name))
        AccountsOper.freeze_account(name, 2)
        return ''
    # 验证码错误
    if 'retcode=2070' in login_loop:
        login.error('invalid verification code')
        return 'pinerror'
    # 登录需要输入验证码
    if 'retcode=4049' in login_loop:
        login.warning('account {} need verification for login'.format(name))
        return 'login_need_pincode'

    if '正在登录' in login_loop or 'Signing in' in login_loop:
        pa = r'location\.replace\([\'"](.*?)[\'"]\)'
        return re.findall(pa, login_loop)[0]
    else:
        return ''
示例#2
0
def code_verificate(username,
                    password,
                    filename,
                    codetype=1005,
                    timeout=60,
                    appid=4072,
                    appkey='1be0b9b3382c588d8ffd47db7910bacd'):
    '''
    :param username: 用户名
    :param password: 密码
    :param filename: 图片文件
    :param codetype: 验证码类型,例:1004表示4位字母数字,不同类型收费不同。
    :param timeout: 超时时间,秒
    :param appid: 软件ID,开发者分成必要参数
    :param appkey: 软件密钥,开发者分成必要参数
    :return: 验证码结果
    '''
    yundama = YDMHttp(username, password, appid, appkey)
    uid = yundama.login()
    # print('uid: %s' % uid)
    balance = yundama.balance()
    # print('balance: %s' % balance)
    if balance <= 0:
        raise Exception('云打码已经欠费了,请及时充值')
    elif balance <= 100:
        login.warning('云打码余额已不多,请注意及时充值')
    cid, result = yundama.decode(filename, codetype, timeout)
    # login.info('cid: %s, result: %s' % (cid, result))
    return result, yundama, cid
示例#3
0
def remove_cookies(name):
    Cookies.delete_cookies(name)
    AccountsOper.freeze_account(name, 1)
    cookieNum = Cookies.get_cookies_num()
    login.info("The num of the cookies is %s" % cookieNum)
    if not cookieNum:
        login.warning('Stopping...')
        os.system('pause')
示例#4
0
def update_cookies(name):
    account = AccountsOper.get_account_info_by_name(name)
    if account:
        session = get_session(account.name, account.password)
        if session:
            login.warning("The cookie of %s has been updated successfully!" % name)
        else:
            login.warning("The cookie of %s updated failed! Remove it!" % name)
示例#5
0
def init_cookies():
    accounts = AccountsOper.get_account_info()
    for account in accounts:
        if not Cookies.get_cookies(account.name):
            get_session(account.name, account.password)
            time.sleep(3)
    cookieNum = Cookies.get_cookies_num()
    login.info("The num of the cookies is %s" % cookieNum)
    if not cookieNum:
        login.warning('Stopping...')
        os.system('pause')
示例#6
0
 def check_cookies_timeout(cls, cookies):
     if not cookies:
         return True
     if isinstance(cookies, bytes):
         cookies = cookies.decode('utf-8')
     cookies = json.loads(cookies)
     login_time = datetime.datetime.fromtimestamp(cookies['loginTime'])
     if datetime.datetime.now() - login_time > datetime.timedelta(
             hours=cookie_expire_time):
         login.warning('The account has been expired')
         return True
     return False