Python 最新版破解滑块验证码自动登录QQ空间
本节所讲内容:
Selenium+Python环境搭建及配置
滑块验证码步骤分解
QQ空间破解滑块验证码登录(全部代码请看最后)
1.1 selenium 介绍
1.2 selenium+Python环境配置
前提条件:已安装好Python开发环境(python3.7.2),这是最基本的呦~
安装步骤:
1. 安装selenium:pip install selenium
2. 安装webdriver
各大浏览器webdriver地址可参见:https://docs.seleniumhq.org/download/
Firefox:https://github.com/mozilla/geckodriver/releases/
Chrome:https://sites.google.com/a/chromium.org/chromedriver/ 或者
http://chromedriver.storage.googleapis.com/index.html
IE:http://selenium-release.storage.googleapis.com/index.html
注:webdriver需要和对应的浏览器版本以及selenium版本对应
Webdriver版本
支持的Chrome版本
v2.41
v67-69
v2.40
v66-68
v2.39
v66-68
v2.38
v65-67
v2.37
v64-66
v2.36
v63-65
v2.35
v62-64
v2.34
v61-63
3. webdriver安装路径
Win:复制webdriver到Python安装目录下或者在path中配置下路径(方便python能快速寻找)
2. 滑块验证码步骤分解
第一步:访问QQ空间登录网址,定位iframe登录标签,点击账号密码
代码实现:
driver = webdriver.Chrome()
driver.set_window_position(900, 10)
driver.maximize_window()
driver.get(url)
#切换frame
driver.switch_to.frame('login_frame')
#点击
driver.find_element_by_id("switcher_plogin").click()
第二步:跳转到输入界面,然后清空每个输入框的数据然后在点击登录
代码实现:
# 输入用户名和密码
driver.find_element_by_id('u').clear()
driver.find_element_by_id('u').send_keys('3403073998')
driver.find_element_by_id('p').clear()
driver.find_element_by_id('p').send_keys('family521@#!')
sleep(1)# 点击登录
driver.find_element_by_id('login_button').click()
sleep(5)
第三步:再次定位到iframe按钮操作并进行拖拽,距离我们保持固定180,图片让它更换底板图片
在这个地方需要注意点的是我们并没有对滑块移动的距离进行确定,
只是写一个distances=180这个固定的距离,
当然在这个拉取的过程中每次拉取也有可能失败,这是正常现象,请各位拿到代码后运行下
代码实现:
# 切换iframe
try:iframe = driver.find_element_by_xpath('//iframe')
except Exception as e:pass
sleep(2) # 等待资源加载driver.switch_to.frame(iframe)# 等待图片加载出来
WebDriverWait(driver, 5, 0.5).until(EC.presence_of_element_located((By.ID, "tcaptcha_drag_button"))
)
try:button = driver.find_element_by_id('tcaptcha_drag_button')
except Exception as e:passsleep(1)
# 开始拖动 perform()用来执行ActionChains中存储的行为
#distance 代表的是滑块移动的距离,我们这里直接写死
distance = 180
times = 0
while True:try:action = ActionChains(driver)#点击鼠标并进行拖拽action.click_and_hold(button).perform()# 清除之前的actionaction.reset_actions()#模拟轨迹方程track = get_track(distance)#开始模拟拖拽for i in track:#y轴不偏移,x轴持续滑动action.move_by_offset(xoffset=i, yoffset=0).perform()action.reset_actions()sleep(0.5)#释放鼠标action.release().perform()sleep(5)times += 1print('这是第{}次'.format(times))except:print('登录成功')break
轨迹方程:(为了模仿人为的动作,防止整理)
def get_track(distance):"""根据偏移量获取移动轨迹:param distance: 偏移量:return: 移动轨迹"""# 移动轨迹track = []# 当前位移current = 0# 减速阈值mid = distance * 4 / 5# 计算间隔t = 1# 初速度# v = 0v = 0while current < distance:if current < mid:# 加速度为正2# a_b = 8a = 10else:# 加速度为负3a = -3# 初速度v0v0 = v# 当前速度v = v0 + atv = v0 + a * t# 移动距离x = v0t + 1/2 * a_b * t^2move = v0 * t + 1 / 2 * a * t * t# 当前位移current += move# 加入轨迹track.append(round(move))return track
3. QQ空间破解滑块模拟登录全部代码
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @Time : 2020/2/21 21:18
# @Author : Xuegod Teacher For
# @File : qq空间.py
from time import sleep
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWaiturl = 'https://i.qq.com'def get_track(distance):"""根据偏移量获取移动轨迹:param distance: 偏移量:return: 移动轨迹"""# 移动轨迹track = []# 当前位移current = 0# 减速阈值mid = distance * 4 / 5# 计算间隔t = 1# 初速度# v = 0v = 0while current < distance:if current < mid:# 加速度为正2# a_b = 8a = 10else:# 加速度为负3a = -3# 初速度v0v0 = v# 当前速度v = v0 + atv = v0 + a * t# 移动距离x = v0t + 1/2 * a_b * t^2move = v0 * t + 1 / 2 * a * t * t# 当前位移current += move# 加入轨迹track.append(round(move))return trackdef main():driver = webdriver.Chrome()driver.set_window_position(900, 10)driver.maximize_window()driver.get(url)driver.switch_to.frame('login_frame')driver.find_element_by_id("switcher_plogin").click()sleep(1)# 输入用户名和密码driver.find_element_by_id('u').clear()driver.find_element_by_id('u').send_keys('你的QQ账号')driver.find_element_by_id('p').clear()driver.find_element_by_id('p').send_keys('你的QQ密码')sleep(1)# 点击登录driver.find_element_by_id('login_button').click()sleep(5)# 切换iframetry:iframe = driver.find_element_by_xpath('//iframe')except Exception as e:passsleep(2) # 等待资源加载driver.switch_to.frame(iframe)# 等待图片加载出来WebDriverWait(driver, 5, 0.5).until(EC.presence_of_element_located((By.ID, "tcaptcha_drag_button")))try:button = driver.find_element_by_id('tcaptcha_drag_button')except Exception as e:passsleep(1)# 开始拖动 perform()用来执行ActionChains中存储的行为distance = 180times = 0while True:try:action = ActionChains(driver)#点击鼠标并进行拖拽action.click_and_hold(button).perform()# 清除之前的actionaction.reset_actions()#模拟轨迹方程track = get_track(distance)#开始模拟拖拽for i in track:#y轴不偏移,x轴持续滑动action.move_by_offset(xoffset=i, yoffset=0).perform()action.reset_actions()sleep(0.5)#释放鼠标action.release().perform()sleep(5)times += 1print('这是第{}次'.format(times))except:print('登录成功')breakprint(driver.title)sleep(2)driver.quit()print("finish~~")if __name__ == '__main__':main()
Python 最新版破解滑块验证码自动登录QQ空间相关推荐
- python+selenium自动登录qq空间并下载相册
基于selenium的自动登录qq空间并遍历所有相册及相片的功能.只能访问自己或好友(有访问权限)的相册,好友有密码的相册不可能...这里只是介绍流程,所以只是实现了遍历,并未实现图片文件的下载保存. ...
- Selenium基础知识 自动登录QQ空间
Selenium基础知识 自动登录QQ空间 from selenium import webdriver import timedef auto_login():driver = webdriver. ...
- selenium破解滑块验证码自动查询+获取后续表单数据
一.装载好chromedriver之后,运行命令行 "chrome.exe"(路径) --remote-debugging-port=9222 打开谷歌浏览器. 二.使用selen ...
- Python学习笔记(二):利用Selenium一键自动登录QQ空间、百度等网站
曾经在学校闲的时候,见到有人通过程序自动登录百度等网站,觉得很厉害.实习的时候,偶然的机会也研究了一下,有空的时候试试运行就自动点赞,觉得还比较有意思,可以用来装装X,哈哈. 一.python环境 第 ...
- php自动登录QQ空间,QQ空间自动登录 - brivio的个人页面 - OSCHINA - 中文开源技术交流社区...
#自动登录 define('ROOT_PATH',__DIR__); include_once(ROOT_PATH.'/lib/Http.class.php'); $config=array( 'us ...
- 自动登录QQ空间 --- Selenium打开带有xpath-helper的chrom
1.导入相关库 from selenium.webdriver.common.keys import Keys import time from selenium import webdriver 2 ...
- python自动登录qq空间_python 利用splinter组件,自动登录QQ空间
1.需要下载splinter 2.下载chromedriver放在/usr/bin目录下 #!/usr/bin/env python import sys import time from splin ...
- selenium自动登录QQ空间(无头、规避)
无头参数设置: from selenium.webdriver.edge.options import Options options = Options() options.add_argument ...
- Python Selenium破解滑块验证码最新版!
通过率高达百分之95!真的强! 一.滑块验证码简述 有爬虫,自然就有反爬虫,就像病毒和杀毒软件一样,有攻就有防,两者彼此推进发展.而目前最流行的反爬技术验证码,为了防止爬虫自动注册,批量生成垃圾账号, ...
- Python高效实现滑块验证码自动操纵
CDA数据分析师 出品作者:CDALevel Ⅰ 持证人岗位:数据分析师 行业:大数据 众所周知,规范性的网络爬虫可以帮助Decision-maker在低成本下获得想要的信息,不仅如此,做科研.写论文 ...
最新文章
- 慕课python课后作业_python基础1习题练习
- 使用OpenSSL进行RSA加密和解密(非对称)
- SetWindowPos()详解
- 【算法导论】【排序】—— 计数排序(counting sort)
- 数论入门 2021-2-28
- 中文核心期刊目录(2014 年版)北大核心目录(第七版)新鲜出炉
- 选择IT行业的自我心得,希望能帮助到各位!(一)
- 使用Photoshop去掉图片上的文字的几种方法
- 计算机网络管理公开课观后感,青年网络公开课观后感
- Wamp安装教程(Windows Apache Mysql PHP集成安装环境)
- 从软件工程的角度写机器学习1——机器学习的思想
- ambari 修改服务器名,ambari - Ambari无法运行用于修改用户配置单元的自定义钩子 - 堆栈内存溢出...
- 《Happy Birthday》游戏开发记录(送给朋友的小礼物)
- MySQL 8.0.16安装教程(windows 64位)
- MySQL基础教程 包含SQL语句、约束、表关系、设计范式、多表、事务等
- 全网首创Python影视剧解说视频文字自动剪辑第1版
- fred dataset_Excel经济数据加载项:FRED
- PSINS中19维组合导航模块sinsgps详解(滤波部分)
- 浅谈防火墙、IDS和IPS之间的区别
- [转]敏感信息识别方法探究