Python 点击指定位置验证码破解的实现代码
2019-09-11 10:28
1026 查看
思路:
创建浏览器驱动对象
加载登录页面
等待页面加载完毕
切换到用户名和密码登录模式
输入手机号, 注意此处需要等待并获取输入框
输入密码
点击验证按钮
获取弹出验证图片
使用超级鹰打码平台识别图形的坐标
获取到坐标信息, x,y坐标分别除以2; 由于电脑分辨率太过了, 是原来的两倍, 如果是普通分辨率可以除以2,直接用就可以了.
把鼠标移动到, 坐标点的位置进行点击
点击登录按钮
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver import ActionChains import time # 导入超级鹰 from chaojiying import chaojiying #根据系统,可能截图不成功,需要使用无头浏览,mac系统可以不设置 options=webdriver.ChromeOptions() options.headless=True driver=webdriver.Chrome(options=potions) driver.get('http://www.zhaopingou.com/signin') driver.find_element_by_class_name('li02').click() wait=WebDriverWait(driver,20,0.5) # 账号登录 login_phone=wait.until(EC.visibility_of_element_located((By.ID,'pwd_login_phone'))) login_phone.send_keys('17724035140') # 密码 driver.find_element_by_id('form_login_password').send_keys('961831740hzll') # 点击获取图片 captcha = wait.until(EC.visibility_of_element_located((By.XPATH, '//div[@class="phone_login_pwd"]//iframe[starts-with(@id, "captcha_widget")]'))) captcha.click() # 点击 # 保存图片(可以不保存) captcha_element = wait.until(EC.visibility_of_element_located((By.XPATH, '//body[@class="graybc"]//iframe[starts-with(@id, "captcha_frame")]'))) captcha_element.screenshot('zhaopingou.png') # 将图片转换为二进制 bytes_img=captcha_element.screenshot_as_png # print(bytes_img) result=chaojiying.post_pic(bytes_img,'9101') x,y=result['pic_str'].split(',') print(x,y) x=int(x) y=int(y) # ActionChains(driver).move_to_element_with_offset(bytes_img,x,y).click().perform() ActionChains(driver).move_to_element_with_offset(captcha_element, x, y).click().perform() time.sleep(2) driver.find_element_by_id('free_login_btn').click() print(driver.window_handles) driver.switch_to.window(driver.window_handles[0]) # time.sleep(5) driver.quit()
以上就是本文的全部内容,希望对大家的学习有所帮助
您可能感兴趣的文章:
相关文章推荐
- Python + selenium + requests实现12306全自动抢票及验证码破解加自动点击功能
- c#winform中实现指定窗口位置鼠标点击
- Unity3D之实现点击地形使物体移动到指定位置
- python实现带验证码网站的自动登陆实现代码
- JQUERY实现点击INPUT使光标移动到最后或指定位置
- 一个有n个整数的递增有序数组。对它进行向左或向右循环移动若干次后,要求给出一个代码实现,尽可能快地从这个数组中寻找指定值所在的位置
- Android的一段常用动画效果代码(如何让点击的图片控件加速飞入到指定位置)
- JavaScript talbe表中指定位置插入一行的实现代码 脚本之家修正版
- 请教一个python问题,如何返回到指定的代码行?经小杰大牛指点,终于实现了。
- Python 中Django验证码功能的实现代码
- JavaScript--点击按钮实现选中选项移动到指定位置(下拉框)或全部选项移动
- 如何用jquery实现点击后跳到页面指定位置
- python中实现指定时间调用函数示例代码
- LTE-TDD measurement gaps位置计算--Python代码实现
- python自动登录12306并自动点击验证码完成登录的实现源代码
- python实现指定文件夹下的指定文件移动到指定位置
- html js点击含id的 标签实现form表单跳转到指定的标签位置
- 微信小程序实现定位及到指定位置导航的示例代码
- 基于jquery的从一个页面跳转到另一个页面的指定位置的实现代码(带平滑移动的效果)
- 基于jquery的从一个页面跳转到另一个页面的指定位置的实现代码