Exemple #1
0
 def do_getcode(self, phone):
     if phone == '':
         print('请输入手机号码作为参数')
         return
     code = jiema.RecvCodeGetCode(phone)
     if code == False:
         print('获取验证码失败')
         return
     print('接码平台验证码获取成功, ' + phone + ' ' + code)
Exemple #2
0
def RegisterOneAccount():
    ou = dict(error=0, data=dict(), msg='ok')
    ##注册前 重启modem
    airtel.AirtelReboot()

    ##第一步 获取手机号码
    phone = jiema.RecvCodeGetPhone()
    if phone == False:
        ou['error'] = 5
        ou['msg'] = '获取手机号码失败'
        return ou
    print('phone: ' + phone)

    ##第二步 发送验证码
    ou = SendCode(phone)
    if ou['error'] != 0:
        return ou

    time.sleep(20)
    ##第三步 接收验证码
    code = jiema.RecvCodeGetCode(phone)
    if code == False:
        ou['error'] = 6
        ou['msg'] = '获取验证码失败'
        ou['data'].clear()
        return ou

    ##第四步 注册
    #产生随机密码
    pwd = RandomPasswordGetOne()
    #第二步返回结果中的数值
    challenge = ou['data']['challenge']
    validate = ou['data']['validate']
    ou['data'].clear()
    logger.debug('phone:%s,code:%s,pwd:%s,challenge:%s,validate:%s', phone,
                 code, pwd, challenge, validate)
    msg = douyu.RegisterSubmit(phone, code, pwd, challenge, validate)
    if msg == False:
        ou['error'] = 7
        ou['msg'] = '注册提交失败'
        ou['data'].clear()
        return ou
    ou['error'] = 0
    ou['msg'] = '提交注册成功'
    ou['data']['nickname'] = msg['nickname']
    ou['data']['pwd'] = pwd
    ou['data']['phone'] = phone
    logger.debug("提交注册成功")
    logger.debug('nickname:%s,phone:%s, pwd:%s', msg['nickname'], phone, pwd)

    return ou
Exemple #3
0
 def do_getcode(self, phone):
     if phone == '':
         print('请输入手机号码作为参数')
         return
     if CONF['useyzm'] == True:
         jm = jsyzm.JSJM()
         ou = jm.getCode(phone)
         if ou['error'] != '0':
             print('获取短信失败,error=' + ou['error'] + ' msg=' + ou['msg'])
             return
         code = ou['data']['code']
     else:
         code = jiema.RecvCodeGetCode(phone)
         if code == False:
             print('获取验证码失败')
             return
     print('接码平台验证码获取成功, ' + phone + ' ' + code)
Exemple #4
0
def RegisterOneAccountV5(reset=True):
    """
    功能:注册一个账号,使用浏览器模式,人工参与,返回账号信息
    输入产生:reset
                    True  重启modem
                    False 不重启modem
    输出参数:ou:字典,包含账号信息
                ou['data']['nickname'] : 用户名
                ou['data']['pwd']      : 密码
                ou['data']['phone']    : 绑定的手机号码
                ou['msg']      : 信息
                ou['error']             : 0 ok
                                        : 1 手机号码无效
                                        : 2 获取gt和challenge失败
                                        : 3 极验获取challenge和validate失败
                                        : 4 验证码发送失败
                                        : 5 获取手机号码失败
                                        : 6 获取验证码失败
                                        : 7 注册提交失败
                                        : 8 点击验证码失败
                                        : 9 验证码打码失败
    """
    ou = dict(error=0, data=dict(), msg='ok')
    ##注册前 重启modem
    if reset == True:
        ModemReboot()

    ##第一步 获取手机号码
    if CONF['useyzm'] == True:
        jm = jsyzm.JSJM()
        ou = jm.getPhone()
        if ou['error'] != '0':
            logger.error('获取号码失败,error=%s,msg=%s', ou['error'], ou['msg'])
            return ou
        phone = ou['data']['phone']
    else:
        phone = jiema.RecvCodeGetPhone()
        if phone == False:
            ou['error'] = 5
            ou['msg'] = '获取手机号码失败'
            return ou
    #print('phone: ' + phone)

    #phone = '15915492613'
    ##第二步 产生随机密码
    pwd = RandomPasswordGetOne()

    ##第三步 发送验证码
    crack = douyuRegister.DouyuRegister(phone, pwd)
    if CONF['usedati'] != True:
        rv = crack.sendcode()
        if rv == True:
            logger.debug('验证码发送成功,准备接收验证码')
        else:
            ou['error'] = 4
            ou['msg'] = '验证码发送失败'
            return ou
    else:
        #保存验证码图片
        png = crack.get_png()
        if png != False:
            logger.debug('验证码图片保存成功,准备识别图片')
        else:
            ou['error'] = 4
            ou['msg'] = '验证码图片保存失败'
            return ou
        #识别验证码图片
        dama = jsdati.JSDATI(png)
        location = dama.verifyPic('word')
        if location == False:
            logger.error('验证码打码失败')
            ou['error'] = 9
            ou['msg'] = '验证码打码失败'
            return ou
        rv = crack.click_word(location)
        if rv == False:
            logger.error('点击验证码失败')
            ou['error'] = 8
            ou['msg'] = '点击验证码失败'
            return ou
    time.sleep(20)
    ##第三步 接收验证码
    if CONF['useyzm'] == True:
        ou = jm.getCode(phone)
        if ou['error'] != '0':
            logger.error('获取短信失败,error=' + ou['error'] + ' msg=' + ou['msg'])
            return ou
        code = ou['data']['code']
    else:
        code = jiema.RecvCodeGetCode(phone)
        if code == False:
            ou['error'] = 6
            ou['msg'] = '获取验证码失败'
            ou['data'].clear()
            return ou

    ##第四步 设置验证码
    crack.setcode(code)

    #第五步 提交注册
    ou['data'].clear()
    logger.debug('phone:%s,code:%s,pwd:%s', phone, code, pwd)
    rv = crack.register()
    if rv == False:
        ou['error'] = 7
        ou['msg'] = '注册提交失败'
        ou['data'].clear()
        return ou

    ##第六步 获取nickname
    nickname = crack.get_nickname()
    ##第七步 获取cookie
    cookie = crack.get_cookie()
    ou['error'] = 0
    ou['msg'] = '注册成功'
    ou['data']['nickname'] = nickname
    ou['data']['phone'] = phone
    ou['data']['pwd'] = pwd
    ou['data']['cookie'] = cookie

    ##第八步 获取站内信
    validate = crack.get_umes()
    ou['data']['validate'] = validate
    logger.debug("注册成功")
    #logger.debug('nickname:%s,phone:%s, pwd:%s, validate:%s, cooike:%s', nickname, phone, pwd, format(validate,""), cookie)
    logger.debug('nickname:%s,phone:%s, pwd:%s, cooike:%s', nickname, phone,
                 pwd, cookie)

    return ou
Exemple #5
0
def RegisterOneAccount():
    """
    功能:注册一个账号,使用api方式,返回账号信息
    输入产生:无
    输出参数:ou:字典,包含账号信息
                ou['data']['nickname'] : 用户名
                ou['data']['pwd']      : 密码
                ou['data']['phone']    : 绑定的手机号码
                ou['msg']      : 信息
                ou['error']             : 0 ok
                                        : 1 手机号码无效
                                        : 2 获取gt和challenge失败
                                        : 3 极验获取challenge和validate失败
                                        : 4 验证码发送失败
                                        : 5 获取手机号码失败
                                        : 6 获取验证码失败
                                        : 7 注册提交失败
    """
    ou = dict(error=0, data=dict(), msg='ok')
    ##注册前 重启modem
    ModemReboot()

    ##第一步 获取手机号码
    phone = jiema.RecvCodeGetPhone()
    if phone == False:
        ou['error'] = 5
        ou['msg'] = '获取手机号码失败'
        return ou
    print('phone: ' + phone)

    ##第二步 发送验证码
    ou = SendCode(phone)
    if ou['error'] != 0:
        return ou

    time.sleep(20)
    ##第三步 接收验证码
    code = jiema.RecvCodeGetCode(phone)
    if code == False:
        ou['error'] = 6
        ou['msg'] = '获取验证码失败'
        ou['data'].clear()
        return ou

    ##第四步 注册
    #产生随机密码
    pwd = RandomPasswordGetOne()
    #第二步返回结果中的数值
    challenge = ou['data']['challenge']
    validate = ou['data']['validate']
    ou['data'].clear()
    logger.debug('phone:%s,code:%s,pwd:%s,challenge:%s,validate:%s', phone,
                 code, pwd, challenge, validate)
    msg = douyu.RegisterSubmit(phone, code, pwd, challenge, validate)
    if msg == False:
        ou['error'] = 7
        ou['msg'] = '注册提交失败'
        ou['data'].clear()
        return ou
    ou['error'] = 0
    ou['msg'] = '提交注册成功'
    ou['data']['nickname'] = msg['nickname']
    ou['data']['pwd'] = pwd
    ou['data']['phone'] = phone
    logger.debug("提交注册成功")
    logger.debug('nickname:%s,phone:%s, pwd:%s', msg['nickname'], phone, pwd)

    return ou
Exemple #6
0
def RegisterOneAccountV5():
    ou = dict(error=0, data=dict(), msg='ok')
    ##注册前 重启modem
    airtel.AirtelReboot()

    ##第一步 获取手机号码
    phone = jiema.RecvCodeGetPhone()
    if phone == False:
        ou['error'] = 5
        ou['msg'] = '获取手机号码失败'
        return ou
    #print('phone: ' + phone)

    ##第二步 产生随机密码
    pwd = RandomPasswordGetOne()

    ##第三步 发送验证码
    crack = douyuRegister.DouyuRegister(phone, pwd)
    rv = crack.sendcode()
    if rv == True:
        logger.debug('验证码发送成功,准备接收验证码')
    else:
        ou['error'] = 4
        ou['msg'] = '验证码发送失败'
        return ou

    time.sleep(20)
    ##第三步 接收验证码
    code = jiema.RecvCodeGetCode(phone)
    if code == False:
        ou['error'] = 6
        ou['msg'] = '获取验证码失败'
        ou['data'].clear()
        return ou

    ##第四步 设置验证码
    crack.setcode(code)

    #第五步 提交注册
    ou['data'].clear()
    logger.debug('phone:%s,code:%s,pwd:%s', phone, code, pwd)
    rv = crack.register()
    if rv == False:
        ou['error'] = 7
        ou['msg'] = '注册提交失败'
        ou['data'].clear()
        return ou

    ##第六步 获取nickname
    nickname = crack.get_nickname()
    ##第七步 获取cookie
    cookie = crack.get_cookie()
    ou['error'] = 0
    ou['msg'] = '注册成功'
    ou['data']['nickname'] = nickname
    ou['data']['phone'] = phone
    ou['data']['pwd'] = pwd
    ou['data']['cookie'] = cookie

    logger.debug("注册成功")
    logger.debug('nickname:%s,phone:%s, pwd:%s, cooike:%s', nickname, phone,
                 pwd, cookie)

    return ou