Beispiel #1
0
def step2(args, browser):
    browser.find_elements_by_class_name('cube-input-field')[0].send_keys(
        args.loginID)  #登陆号
    browser.find_elements_by_class_name('cube-input-field')[1].send_keys(
        smstel)  #手机号
    # s=input('test:')
    if args.robot: saveFileRobot('获取短信验证码')
    flag = 2
    while 1:
        browser.find_element_by_class_name('getCode').click()  #点击获取验证码
        time.sleep(2)
        if '重新获取' in browser.find_element_by_class_name('getCode').text:
            while 1:
                if args.env == 'c':
                    SMScode = getSMScode(smstel,
                                         waiteSec=flag,
                                         menhuPath=args.path)  #获取短信验证码
                elif args.env in ['s', 'p']:
                    if args.robot:
                        sendInput('请发送短信验证码,格式:验证码 xxxx')
                        SMScode = getInput('验证码')
                    else:
                        SMScode = input('输入短信验证码,退出请按q:')
                if SMScode == 'q': sys.exit(0)
                browser.find_elements_by_class_name(
                    'cube-input-field')[2].clear()  #清除
                browser.find_elements_by_class_name(
                    'cube-input-field')[2].send_keys(SMScode)  #输入短信验证码
                browser.find_elements_by_class_name(
                    'cube-input-field')[3].clear()  #清除
                browser.find_elements_by_class_name(
                    'cube-input-field')[3].send_keys(fake.email())  #邮箱
                browser.find_element_by_class_name('next').click()  #下一步
                time.sleep(1)
                try:
                    tips = browser.find_elements_by_class_name(
                        'cube-toast-tip')[1].get_attribute('innerHTML')
                except:
                    tips = ''
                if '短信验证码输入有误' in tips:
                    flag += 1
                    if waiteSec(browser): break
                else:
                    time.sleep(1)
                    return browser
Beispiel #2
0
def LoginBboss(env='c', username='', passwoard='', **bro):
    username = username if username else countBB[env]['usernameBB']
    passwoard = passwoard if passwoard else countBB[env]['passwordBB']
    if env in 'cps':
        try:
            BBTel = BBTelDic[env][username]
        except KeyError:
            print(f'config.py中BBTelDic没有{username}的电话号码')
            sys.exit()
    chrome_option = webdriver.ChromeOptions()
    chrome_option.add_argument('disable-infobars')
    browser = webdriver.Chrome(
        options=chrome_option) if not bro else bro['bro']
    codeurl = f"{BBloginDomainDic[env]}/yzmkaptcha"
    browser.maximize_window()
    browser.get(
        f'{BBloginDomainDic[env]}/login?service={BBdomainDic[env]}/pbs/page/pbsAuditService/manager.html'
    )
    while True:
        cookie_without_login = "******".join([
            item["name"] + "=" + item["value"]
            for item in browser.get_cookies()
        ])
        try:
            unameEle = browser.find_element_by_id('username')
        except SCENSEE:
            break
        unameEle.clear()
        unameEle.send_keys(username)
        pwdEle = browser.find_element_by_id('password')
        pwdEle.clear()
        pwdEle.send_keys(passwoard)
        codeEle = browser.find_element_by_id('captcha')
        if env in 'c': code = '6666'
        else: code = GetcodePic(cookie_without_login, codeurl)
        codeEle.clear()
        codeEle.send_keys(code)
        if env in 'ps':
            browser.find_element_by_id('getMsg').click()  #点击获取验证码
            time.sleep(1)
            alertEle = browser.switch_to.alert
            alertText = alertEle.text
            alertEle.accept()
            if '失败' in alertText: continue
            elif '五分钟' in alertText:
                code = GetcodePic(cookie_without_login, codeurl)
                codeEle.clear()
                codeEle.send_keys(code)
            smsCode = getSMScode(BBTel, timeout=300)
            # smsCode=input(f'输入大总管 {username} 验证码:')
            # print('smsCode: ',smsCode)
            browser.find_element_by_id('msgCaptcha').send_keys(smsCode)
        browser.find_element_by_id('btn-submit').click()
        time.sleep(2)
        try:
            browser.find_element_by_id('captcha')
        except SCENSEE:
            break
    cookieLogined = ";".join(
        [item["name"] + "=" + item["value"] for item in browser.get_cookies()])
    saveCookie(cookieLogined, f'BB_{env}')
    return browser, cookieLogined
Beispiel #3
0
def step1(args, **bro):  #选择平台号
    global envDict
    envDict = {'c': '一体化 测试', 'p': '一体化 准生产', 's': '一体化 生产'}
    chrome_option = webdriver.ChromeOptions()
    chrome_option.add_argument('disable-infobars')
    browser = webdriver.Chrome(
        options=chrome_option) if not bro else bro['bro']
    browser.set_window_size(450, 720)
    browser.implicitly_wait(5)
    browser.get(
        f'{H5domainDic[args.env]}/subapps/bpep-credit-h5/index.html#/baitiaoagreement'
    )
    if saveToMysql:
        print(
            f"\n{envDict[args.env]} {time.strftime('%Y-%m-%d %X',time.localtime())}"
        )
    else:
        save_file(
            f"\n{envDict[args.env]} {time.strftime('%Y-%m-%d %X',time.localtime())}"
        )
    if args.robot:
        saveFileRobot(
            f"\n{envDict[args.env]} {time.strftime('%Y-%m-%d %X',time.localtime())}"
        )
    browser = waitTo(browser, (SCENSEE, SCEENVE, SCESERE),
                     way='tag_name',
                     name='button',
                     operate='click')  #点击同意协议
    time.sleep(1)
    browser = waitTo(browser, (SCENSEE, SCEENVE, SCESERE),
                     way='class',
                     name='cube-form-field',
                     operate='click')  #点击所属平台
    time.sleep(0.5)
    browser.find_element_by_css_selector('.cube-picker-confirm').click()  #点击确定
    time.sleep(0.5)
    browser.find_elements_by_class_name('cube-input-field')[0].send_keys(
        args.loginID)  #登陆号
    browser.find_elements_by_class_name('cube-input-field')[1].send_keys(
        smstel)  #手机号
    if args.robot: saveFileRobot('获取短信验证码')
    flag = 2
    while 1:
        browser.find_element_by_class_name('getCode').click()  #点击获取验证码
        time.sleep(1)
        if '重新获取' in browser.find_element_by_class_name('getCode').text:
            while 1:
                if args.env == 'c':
                    time.sleep(2)
                    SMScode = getSMScode(smstel,
                                         waiteSec=flag,
                                         menhuPath=args.path)  #获取短信验证码
                elif args.env in ['s', 'p']:
                    if args.robot:
                        sendInput('请发送短信验证码,格式:验证码 xxxx')
                        SMScode = getInput('验证码')
                    else:
                        SMScode = input('输入短信验证码,退出请按q:')
                if SMScode == 'q': sys.exit(0)
                browser.find_elements_by_class_name(
                    'cube-input-field')[2].clear()  #清除
                browser.find_elements_by_class_name(
                    'cube-input-field')[2].send_keys(SMScode)  #输入短信验证码
                browser.find_elements_by_class_name(
                    'cube-input-field')[3].clear()  #清除
                browser.find_elements_by_class_name(
                    'cube-input-field')[3].send_keys(fake.email())  #邮箱
                browser.find_element_by_class_name('next').click()  #下一步
                time.sleep(1)
                try:
                    tips = browser.find_elements_by_class_name(
                        'cube-toast-tip')[1].get_attribute('innerHTML')
                except:
                    tips = ''
                if '短信验证码输入有误' in tips:
                    flag += 1
                    if waiteSec(browser): break
                else:
                    time.sleep(1)
                    return browser
Beispiel #4
0
def step1(args, **bro):  #设置登录号
    global envDict
    envDict = {'c': 'H5 测试', 's': 'H5 生产', 'p': 'H5 准生产'}
    chrome_option = webdriver.ChromeOptions()
    chrome_option.add_argument('disable-infobars')
    chrome_option.add_argument('log-level=3')
    chrome_option.add_experimental_option("mobileEmulation",
                                          {'deviceName': 'Galaxy S5'})
    browser = webdriver.Chrome(
        options=chrome_option) if not bro else bro['bro']
    browser.set_window_size(500, 730)
    browser.get(f'{H5domainDic[args.env]}/subapps/bpep-credit-h5/index.html#/')
    if saveToMysql:
        print(
            f"\n{envDict[args.env]} {time.strftime('%Y-%m-%d %X',time.localtime())}"
        )
    else:
        save_file(
            f"\n{envDict[args.env]} {time.strftime('%Y-%m-%d %X',time.localtime())}"
        )
    if args.robot:
        saveFileRobot(
            f"\n{envDict[args.env]} {time.strftime('%Y-%m-%d %X',time.localtime())}"
        )
    browser = waitTo(browser, (SCENSEE, SCEWDE),
                     way='xpath',
                     name='//*[@id="id1"]/div[2]/div[1]/div/input',
                     operate='send_keys',
                     value=args.loginID)  #登录号
    browser.find_element_by_xpath(
        '//*[@id="id2"]/div[2]/div[1]/div/input').send_keys(args.companyName)
    browser.find_element_by_xpath(
        '//*[@id="id3"]/div[2]/div[1]/div/input').send_keys(args.legalTel)
    if args.robot: saveFileRobot('获取短信验证码')
    flag = 2
    while 1:
        browser.find_element_by_class_name('getCode').click()  #点击获取验证码
        time.sleep(2)
        if '重新获取' in browser.find_element_by_class_name('getCode').text:
            while 1:
                if args.env == 'c':
                    SMScode = getSMScode(args.legalTel,
                                         waiteSec=flag,
                                         menhuPath=args.path)  #获取短信验证码
                elif args.env in ['s', 'p']:
                    if args.robot:
                        sendInput(f'请 {args.legalTel} 发送短信验证码,格式:验证码 xxxx')
                        SMScode = getInput('验证码')
                    else:
                        SMScode = input('输入短信验证码,退出请按q:')
                if SMScode == 'q': sys.exit(0)
                browser.find_element_by_xpath(
                    '//*[@id="id000"]/div[2]/div/input').clear()  #清除
                browser.find_element_by_xpath(
                    '//*[@id="id000"]/div[2]/div/input').send_keys(
                        SMScode)  #输入短信验证码
                browser.find_element_by_class_name('newbtn').click()  #下一步
                time.sleep(1)
                try:
                    tips = browser.find_elements_by_class_name(
                        'cube-toast-tip')[1].get_attribute('innerHTML')
                except:
                    tips = ''
                if '短信验证码输入有误' in tips:
                    flag += 1
                    if waiteSec(browser): break
                else:
                    time.sleep(1)
                    return browser
        else:
            time.sleep(1)
Beispiel #5
0
def loginH5(username='******',passwd='*',loginurl='',env='c',fillLoginID=1,menhuPath='',types='pc',phoneNumber='',**bro):
	if not loginurl:loginurl=f'{H5domainDic[env]}/subapps/bpep-credit-h5/index.html#/login'
	chrome_option=webdriver.ChromeOptions()
	chrome_option.add_argument('disable-infobars')
	browser=webdriver.Chrome(options=chrome_option) if not bro else bro['bro']
	browser.get(loginurl)
	flag=3#密码错误允许尝试的次数
	while flag:
		if types=='pc':
			keyDicts=getKeyDicts(browser)
			if not keyDicts:
				browser.refresh()
				time.sleep(1)
				continue
			for s in passwd:browser.find_element_by_xpath(keyDicts[s]).click()#输入密码
			browser.find_element_by_xpath('/html/body/div[2]/div[2]/ul/li[100]').click()#密码键盘点击确定
			browser.set_window_size(450,720)
		elif types=='phone':
			keyDictsABC=getKeyDictsABC(browser,'btloginKey','/html/body/div[2]/div[2]')
			if not keyDictsABC:
				browser.refresh()
				time.sleep(1)
				continue
			inputABC(browser,passwd,keyDictsABC,'/html/body/div[2]/div[2]')
		if fillLoginID:
			browser.find_elements_by_class_name('cube-input-field')[0].send_keys(username)
		while True:
			################################################################################
			# try:
			# 	code=browser.execute_script("return vue.checkCode")
			# except SCEWDE:
			# 	code=0
			# 	pass
			# if not code:code=getCodeH5(browser)
			################################################################################
			browser.find_element_by_class_name("getCode").click()#点击获取短信验证码
			# browser,text=waitTo(browser,SCENSEE,way='class',name='cube-toast-tip',operate='getText')#获取手机号
			# time.sleep(1)
			# tips=browser.find_element_by_class_name('cube-toast-tip').get_attribute('innerHTML')
			# try:
			# 	phoneNumber=re.search(r'\d+',text).group()
			# except AttributeError:
			# 	print('发送验证码失败:',tips)
			# 	sys.exit()
			if env=='c':
				if not phoneNumber:phoneNumber=getTel(username,path=menhuPath)
				time.sleep(5)
				code=getSMScode(phoneNumber,menhuPath=menhuPath)
				# code='123456'
			else:
				if menhuPath:
					sendInput('请发送短信验证码,格式:验证码 xxxx')
					code=getInput('验证码')
				else:
					code=input(f'输入验证码:')
			# else:
			# 	print('获取手机号异常')
			# 	os.system('pause')
			################################################################################
			# browser.find_element_by_xpath('/html/body/div[1]/div/section/main/form/div[3]/div[2]/div/input').clear()
			# browser.find_element_by_xpath('/html/body/div[1]/div/section/main/form/div[3]/div[2]/div/input').clear()
			# browser.find_element_by_xpath('/html/body/div[1]/div/section/main/form/div[3]/div[2]/div/input').send_keys(code)
			browser.find_elements_by_class_name('cube-input-field')[1].clear()
			browser.find_elements_by_class_name('cube-input-field')[1].send_keys(code)
			browser=waitTo(browser,SCEWDE,way='class',name='loginBtn',operate='click')#点击登陆
			time.sleep(1)
			try:
				tiptext=browser.find_elements_by_class_name('cube-toast-tip')[-1].get_attribute('innerHTML')
				if '密码错误' in tiptext:
					browser.refresh()
					time.sleep(1)
					flag-=1
					break
				elif '验证码错误' in tiptext or '验证码输入有误' in tiptext:
					print(tiptext)
					time.sleep(1)
					continue
				else:return browser
			except (SCENSEE,SCESERE,IndexError):return browser
Beispiel #6
0
async def getSMS(tel,env,status):
	from MClogin import getSMScode
	result=getSMScode(tel,waiteSec=0,robot=1,menhuPath=menhuPath,env=env,status=status)
	return result
Beispiel #7
0
def login(username='******', passwd='*', env='c', menhuPath='', **bro):
    chrome_option = webdriver.ChromeOptions()
    chrome_option.add_argument('disable-infobars')
    browser = webdriver.Chrome(
        options=chrome_option) if not bro else bro['bro']
    loginurl = f'{loginDomainDic[env]}/login?service={domainDic[env]}/login.do?method=login'
    codeurl = f"{loginDomainDic[env]}/vimage.do"
    browser.maximize_window()
    browser.implicitly_wait(5)
    flag = 0
    while True:
        flag += 1
        browser.get(loginurl)
        cookie_without_login = "******".join([
            item["name"] + "=" + item["value"]
            for item in browser.get_cookies()
        ])
        inputusername = browser.find_element_by_id('username')
        inputusername.clear()
        inputusername.send_keys(username)
        try:
            inputpassword = browser.find_element_by_id('loginpwd-self')
        except SCENSEE:
            continue
        browser.find_element_by_id("username").send_keys(Keys.TAB)
        time.sleep(1)
        keyInput(passwd)
        codename = browser.find_element_by_id('verifyCode')
        code = GetcodePic(cookie_without_login, loginurl, codeurl)
        codename.clear()
        codename.send_keys(code)
        #############################################################################
        while 1:
            if flag == 1:
                browser.find_element_by_id('sendSmsBtn').click()
                smstip = browser.find_element_by_id(
                    'sendSmsBtn').get_attribute('value')
                if '已发送' in smstip: break
                else: time.sleep(1)
            else:
                smstip = browser.find_element_by_id(
                    'sendSmsBtn').get_attribute('value')
                if '再次' in smstip:
                    browser.find_element_by_id('sendSmsBtn').click()
                    time.sleep(1)
                    smstip = browser.find_element_by_id(
                        'sendSmsBtn').get_attribute('value')
                    if '已发送' in smstip: break
                    else: time.sleep(1)
                else: time.sleep(1)
        if env in 'kc':
            time.sleep(2)
            phoneNumber = getTel(username, path=menhuPath)
            smsCode = getSMScode(phoneNumber, waiteSec=2, menhuPath=menhuPath)
        else:
            if menhuPath:
                sendInput('请发送短信验证码,格式:验证码 xxxx')
                smsCode = getInput('验证码')
            else:
                smsCode = input('输入验证码:')
        try:
            browser.find_element_by_id('smsCode').send_keys(smsCode)
        except SCEUAPE:
            print(browser.switch_to.alert.text)
            browser.switch_to.alert.accept()
            continue
        #############################################################################
        browser.find_element_by_id('login_button').click()
        time.sleep(5)
        try:
            if browser.find_element_by_id('login_button'): continue
        except SCENSEE:
            break
        except SCEUAPE:
            continue
    cookie_with_login = "******".join(
        [item["name"] + "=" + item["value"] for item in browser.get_cookies()])
    return browser