def __init__(self): self.driver = webdriver.Chrome('C:/chromedriver') self.driver.get('https://jr.yatang.cn') self.driver.maximize_window() self.wait = waittime(self.driver, 30)
def start_br(self): self.msg_var.set('正在启动浏览器...') self.driver = webdriver.PhantomJS() self.driver = webdriver.Chrome('C:/chromedriver') self.driver.get('https://jr.yatang.cn/Financial/welfare') self.driver.maximize_window() self.wait = waittime(self.driver, 10) self.msg_var.set('启动浏览器成功,正在检测登录状态...')
def __init__(self, username, paypwd, passwd="ri123654"): self.username = username self.paypwd = paypwd self.pwd = passwd self.driver = webdriver.Chrome('C:/chromedriver') self.driver.maximize_window() self.wait = waittime(self.driver, 20) self.login() self.driver.get('https://jr.yatang.cn/GradRedPacket')
def login(driver, username, pwd): driver.get('https://jr.yatang.cn/NewLogin/index/referer/') wait = waittime(driver, 20) wait.visibility('css', '#username').send_keys(username) wait.visibility('css', '#password').send_keys(pwd) yzm = img_set(driver, wait) wait.visibility('name', 'sendnumber').send_keys(yzm) select = wait.visibility('id', 'cookietime') Select(select).select_by_value('7200') wait.clickable('css', '#button').click() sleep(1) if '登录' in driver.title: login(driver, username, pwd) return driver '''login_ele=driver.find_element_by_xpath('//*[@id="top"]/div[1]/div/div[2]/a[2]')
def __init__(self, eve, msg_var, commit_bt, miao_bt, stop_bt): super(q_mon, self).__init__() self.eve = eve self.msg_var = msg_var self.commit_bt = commit_bt self.miao_bt = miao_bt self.stop_bt = stop_bt self.nopar = [] self.yuecol = loadcol() self.username = self.yuecol[0] #用户名 self.pwd = self.yuecol[1] #用户密码 self.paypwd = self.yuecol[2] #支付密码 self.par_num = int(self.yuecol[3]) #红包倍数 self.parsex_list = self.yuecol[4].split(',') #红包面值''' self.driver = webdriver.Chrome('C:/chromedriver') self.driver.get('https://jr.yatang.cn/Financial/asset') self.driver.maximize_window() self.wait = waittime(self.driver, 20) self.login()
def img_set(driver): wait = waittime(driver, 5) driver.save_screenshot('f://aa.png') #截取当前网页,该网页有我们需要的验证码 imgelement = wait.visibility( 'css', 'body > div.container > div > div > img.verify-code-img') #定位验证码 location = imgelement.location #获取验证码x,y轴坐标 size = imgelement.size #获取验证码的长宽 rangle = (int(location['x']), int(location['y']), int(location['x'] + size['width']), int(location['y'] + size['height'])) #写成我们需要截取的位置坐标 i = Image.open("f://aa.png") #打开截图 frame4 = i.crop(rangle) #使用Image的crop函数,从截图中再次截取我们需要的区域 imgry = frame4.convert('L') #图像加强,二值化 sharpness = ImageEnhance.Contrast(imgry) sharp_img = sharpness.enhance(2.0) sharp_img.save("f:/image_code.png") #sharp_img=Image.open("f:/image_code.png") text = pytesseract.image_to_string(sharp_img) #使用image_to_string识别验证码 text = re.sub("\W", "", text) print(text) return text
def __init__(self, eve, msg_var, commit_bt, miao_bt, stop_bt, miao_num=None): super(lishitest, self).__init__() self.eve = eve self.msg_var = msg_var self.commit_bt = commit_bt self.miao_bt = miao_bt self.stop_bt = stop_bt self.miao_num = miao_num self.yuecol = loadcol() self.username = self.yuecol[0] #用户名 self.pwd = self.yuecol[1] #用户密码 self.paypwd = self.yuecol[2] #支付密码 self.driver = webdriver.Chrome('C:/chromedriver') #self.driver.get('https://jr.yatang.cn/NewLogin/index/referer/') self.check_zt = False self.driver.maximize_window() self.wait = waittime(self.driver, 20) self.login()
#coding=utf-8 ''' Created on 2016年7月27日 @author: admin ''' from selenium import webdriver from time_out import waittime from getdriver import getdriver case=getdriver() case.openbr() driver=case.geturl() wait=waittime(driver,30) wait.get_ele('id','txtUser').send_keys("13612844278") wait.get_ele('id','txtPass').send_keys('aa123654') wait.get_ele('id','loginBtn').click()