赞
踩
滑块验证码识别方法
1、打开浏览器网址
def get_url(url, user, password): ''' url:网址 user:用户名 password:密码 ''' browser = webdriver.Chrome() browser.get(url) # 浏览器最大化 browser.maximize_window() browser.implicitly_wait(15) wait = WebDriverWait(browser, 10) # 等待页面加载完成 wait.until(EC.presence_of_element_located((By.CLASS_NAME, '元素类名'))) user_input = browser.find_element_by_id('登录元素id') pwd_input = browser.find_element_by_id('密码元素id') # 设置用户名、密码 user_input.send_keys(user) pwd_input.send_keys(password) time.sleep(0.5) return browser
2、获取滑块验证码
def get_position(img_label): panel_height = browser.execute_script('return window.outerHeight - window.innerHeight') location = img_label.location size = img_label.size top, bottom, left, right = location['y'] + panel_height, location['y'] + panel_height + size['height'], location[ 'x'], location['x'] + size[ 'width'] return (left, top, right, bottom) if __name__ == '__main__': flag = 0 for j in range(3): print(f'第{j + 1}次开启网页') browser = get_url('网址', '用户名', '密码') for i in range(4): print(f'第{i + 1}遍登
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。