Python 点击指定位置验证码破解的实现代码
Python  /  管理员 发布于 7年前   187
思路:
创建浏览器驱动对象
加载登录页面
等待页面加载完毕
切换到用户名和密码登录模式
输入手机号, 注意此处需要等待并获取输入框
输入密码
点击验证按钮
获取弹出验证图片
使用超级鹰打码平台识别图形的坐标
获取到坐标信息, x,y坐标分别除以2; 由于电脑分辨率太过了, 是原来的两倍, 如果是普通分辨率可以除以2,直接用就可以了.
把鼠标移动到, 坐标点的位置进行点击
点击登录按钮
from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver import ActionChainsimport time# 导入超级鹰from chaojiying import chaojiying#根据系统,可能截图不成功,需要使用无头浏览,mac系统可以不设置options=webdriver.ChromeOptions()options.headless=Truedriver=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()
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号