手机QQ空间自动点赞登录
学以致用~使用 Appium 模拟人类操控手机行为
V2.0在手机上运行,目前实现以下功能:
1.小黑屋模式,一分钟内给好友发100条消息然后进了好友的小黑屋
2.定时发消息提醒对象多喝热水~
3.对指定好友QQ空间说说自动进行点赞、评论、留言、转发
4.所有赞过自己QQ名片背景墙的好友进行点赞
理论上可以模拟一切人类手指操控手机的行为
技术栈:
Appium + Python + ADB 安卓测试桥
核心部分源码如下:
(纯自己写的,如有您有更好的实现方式请留言)
`
from appium import webdriver
from time import sleep
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.support.wait import WebDriverWait
import datetime
desired_caps = dict()
desired_caps['unicodeKeyboard'] = True #设置编码格式为unicode
desired_caps['resetKeyboard'] = True #隐藏手机键盘
手机参数
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '9'
desired_caps['deviceName'] = 'anyone'
url = 'http://localhost:4723/wd/hub'
应用参数
desired_caps['appPackage'] = 'com.tencent.mobileqq'
desired_caps['appActivity'] = 'com.tencent.mobileqq.activity.SplashActivity' #QQ登录界面
driver = webdriver.Remote(url,desired_caps) #获取driver
driver.implicitly_wait(15) #隐式等待
登录账号密码
datas={}
datas['login_usr'] = "登录的QQ号"
datas['passwd'] = "登录的密码"
datas['searched_qq_number'] = {
'first':'在此输入想要查找的QQ号',
'second':'在此输入想要查找的QQ号',
'third':'在此输入想要查找的QQ号',
'forth':'在此输入想要查找的QQ号',
'fifth':'在此输入想要查找的QQ号'
''
}
chat_mesage = {}
chat_mesage["问候语"]="你好!"
chat_mesage["段子"]= {
"段子0":"有的女孩真的很讲道理的,只要你道歉态度诚恳,哪怕你根本就没错,她们也会原谅你的。",
"段子1":"所有人都关心你飞的高不高 累不累 只有我不一样 我不关心你。"
}
def login():
"""
1.登录
:return:
"""
# 登录界面同意协议
driver.find_element_by_xpath("//*[@text='同意']").click()
# 点击登录按钮
driver.find_element_by_xpath("//*[@text='登录']").click()
# 点击账号框并输入账号(todo:参数化,由外部文件读取)
ele = driver.find_element_by_xpath("//*[@text='QQ号/手机号/邮箱']")
ele.click()
ele.send_keys(datas['login_usr'])
sleep(2)
# 点击密码框输入密码(todo:参数化,由外部文件读取)
ele = driver.find_element_by_xpath("//*[@text='输入密码']")
ele.click()
ele.send_keys(datas['passwd'])
# 点击登录按钮
driver.find_element_by_id("com.tencent.mobileqq:id/login").click()
# 权限申请点击【去授权】按钮
driver.find_element_by_id("com.tencent.mobileqq:id/dialogRightBtn").click()
# 权限请求点击允许(适用于VIVO)
# driver.find_element_by_xpath("//*[@text='允许']").click()
# #点击权限授权确定按钮(适用于华为pad)
driver.find_element_by_id("android:id/button1").click()
return
login()
class EnterIntoChatPage():
"""
1.进入聊天界面
2.发送消息
3.定时发送消息
"""
def __init__(self, searched_qq_number, message, start_time='', end_time='', ontime_message=''):
"""
:param searched_qq_number: 被查找的QQ号码
:param message: 要发送的消息
:param start_time: 定时发送消息模式开始时间,默认为空
:param end_time: 定时发送消息模式截止时间,默认为空
:param ontime_message: 定时发送消息内容,默认为空
"""
self.searched_qq_number = searched_qq_number
self.message = message
self.start_time = start_time
self.end_time = end_time
self.ontime_message = ontime_message
def enter_chat_page(self):
"""
1.进入聊天界面
:return:
"""
# 1.找到搜索框并进行点击
driver.find_element_by_xpath("//*[@content-desc='搜索']").click()
# 2.向搜索框中输入要查找的QQ号(todo:datas['searched_qq_number']['first']first需要修改)
# driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/et_search_keyword']").send_keys(self.searched_qq_number)
driver.find_element_by_id("com.tencent.mobileqq:id/et_search_keyword").send_keys(self.searched_qq_number)
sleep(2)
# 3.点击搜索出联系人进入聊天界面
driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/image']").click()
def send_message(self):
"""
1.发送信息
"""
# 1.点击聊天界面消息输入框并将消息输入输入框
ele = driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/input']")
ele.click()
# TODO:交互实现实时对话
for i in range(1): #range(1)默认为1,小黑屋模式可指定对应数字
ele.send_keys(message)
# 2.点击发送消息按钮
driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/fun_btn']").click()
def send_message_on_time(self):
"""
用于定时发送消息
"""
while True:
# 获取当前系统时间,如果时间是2021-01-23 13:00:00,发送指定消息
curr_time = datetime.datetime.now()
time_str = datetime.datetime.strftime(curr_time, '%Y-%m-%d %H:%M:%S')
if self.start_time <= time_str <= self.end_time:
# 向输入框输入消息
ele = driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/input']")
ele.click()
ele.send_keys("定时发送消息测试,当前时间是 "+ time_str + "要发送的消息是:" + self.ontime_message)
# 点击发送按钮
driver.find_element_by_xpath("//*[@text='发送']").click()
break
elif time_str <= self.start_time:
pass
else:
pass
---------------以下是对EnterIntoChatPage()类的测试---------------
searched_qq_number = datas['searched_qq_number']['second']
message = chat_mesage["段子"]["段子0"]
start_time='2021-01-23 13:33:00'
end_time='2021-01-23 13:33:59'
ontime_message='你好'
action = EnterIntoChatPage(searched_qq_number, message,start_time,end_time,ontime_message)
action.enter_chat_page()
action.send_message()
action.send_message_on_time()
action.enter_personal_data_page()
---------------------------------------------------------------
class EnetrQzone():
"""
用于进入个人信息展示页面进行点赞和进入QQ空间
1.首先进入个人信息展示页面
2.点赞
3.进入QQ空间
"""
def int(self):
""""""
def enter_personal_data_page(self):
"""
1.在聊天界面点击右上角【聊天设置】按钮
2.点击个人头像和昵称一栏进入个人信息展示界面
3.进入个人信息展示页面
"""
#1.调用EnterIntoChatPage()类的enter_chat_page()方法进入聊天界面
EnterIntoChatPage(searched_qq_number, message,start_time,end_time,ontime_message).enter_chat_page()
#2.点击在聊天界面点击右上角【聊天设置】按钮
driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/ivTitleBtnRightImage']").click()
#3.点击个人头像和昵称一栏进入个人信息展示界面
driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/clv']").click()
sleep(5)
def give_like(self):
"""
点赞
TODO:赞显示为花样赞时,无法进行点赞
"""
pass
def qzone_like(self):
"""
1.对个人QQ空间进行点赞
2.通过对话框界面进入,调用send_message函数
:return:
"""
# 1.点击进入空间的按钮(进行判断,若已经开通了小世界,则第二个入口为QQ空间,否则为第一个)
elements = driver.find_elements_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/dkv']")
elements[0].click()
#2.判断空间是否是禁止访问的状态
'''
if driver.find_element_by_xpath("//*[@text='主人设置了权限']"):
print("主人设置了权限")
# 发送返回键模拟手机返回按钮
driver.press_keycode(4)
else:
pass
'''
# 首次进入空间需要滑动一段距离,以防点赞按钮加赞不处理来
# sleep(3)
origin_ele = driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/c53']")
destination_ele = driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/hto']")
driver.drag_and_drop(origin_ele, destination_ele)
# 先找昵称和说说发表时间所在的方框,进行遍历
while True:
elements = driver.find_elements_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/c7p']")
print("Current page click_like_button number is:" + str(len(elements)))
# if current page click_lkie_button number is one,click it one times
if len(elements) == 1:
elements[0].click()
# pass
# if current page click_like_button number >=2,the button is iterated over
elif len(elements) >= 2:
elements[1].click()
# pass
print("------------点赞一轮结束---------------")
origin_eles = driver.find_elements_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/c7y']")
destination_eles = driver.find_elements_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/c4r']")
print("Current page origin_eles numbers:" + str(len(origin_eles)))
print("Current page destination_eles numbers:" + str(len(destination_eles)))
# if current page only have one origin_eles and one destination_eles,direct use of
if len(origin_eles) == 1 and len(destination_eles) == 1:
driver.drag_and_drop(origin_eles[0],destination_eles[0])
# if current page have two desttination_eles and one origin_eles,than Slide from the destination_eles[1] to the destination_eles[1]
elif len(destination_eles) == 2 and len(origin_eles) == 1:
driver.drag_and_drop(destination_eles[1],destination_eles[0])
# if current page have two desttination_eles and one origin_eles,than Slide from the origin_eles[1] to the origin_eles[0]
elif len(origin_eles) == 2 and len(destination_eles) == 1:
driver.drag_and_drop(origin_eles[1],origin_eles[0])
# 如果当前页面有2个滑动起点和2个滑动终点,那么从第2个滑动终点滑动到第1个滑动终点
elif len(origin_eles) == 2 and len(destination_eles) == 2:
driver.drag_and_drop(destination_eles[1],destination_eles[0])
# 如果当前界面有1个滑动起点和0个滑动终点
elif len(origin_eles) == 1 and len(destination_eles) == 0:
origin_ele = driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/c4r']")
destination_ele = driver.find_element_by_xpath("//*[@resource-id='com.tencent.mobileqq:id/c7y']")
driver.drag_and_drop(origin_ele, destination_ele)
# 如果当前界面有1个滑动终点和0个滑动起点
elif len(destination_eles) == 1 and len(origin_eles) == 0:
pass
---------------以下是对EnetrQzone(EnterIntoChatPage)类的测试---------------
action = EnetrQzone()
action.enter_personal_data_page()
action.qzone_like()
---------------------------------------------------------------
`
手机QQ空间自动点赞登录的更多相关文章
- QQ空间自动点赞js脚本
这是很久前写的脚本了,在浏览器打开QQ空间,并在控制台输入代码就可 时间间隔最好开大点,不然容易被暂时冻结账号 function autoLike() { var list=document.getE ...
- QQ空间自动点赞js代码
1.jQuery().each(): each() 方法为每个匹配元素规定要运行的函数. 提示:返回 false 可用于及早停止循环. 函数原型: function(index,element) 为每 ...
- JS/java实现QQ空间自动点赞
使用方法: 1:进入QQ空间 2:复制下面代码 3:按F12或右键审查元素 进入控制台 也就是console 4:粘贴 回车键 喝口水 5:如果嫌慢的话可以 修改这段代码. window.setI ...
- 不用写软件,纯JS 实现QQ空间自动点赞
这里分享一个自己写的点赞JS,已实现了好友动态.右侧栏猜你喜欢 点赞,有兴趣的朋友可以加上去玩玩.打开浏览器的开发者模式运行就可以看到效果了 var count = 0; var total = 0; ...
- QQ空间自动发广告解决方法
最近空间好多人QQ都中了毒.每天我都有几十个好友刷空间话费.流量广告! QQ空间自动发广告的原因: 最近使用了刷赞或者其他QQ外挂软件(有些开发者或破解者会在这样的软件上留后门,请自己判断). 或者最 ...
- 技术揭秘“QQ空间”自动转发不良信息
大家经常会看到QQ空间自动转发一些附带链接的不良信息,即便我们的QQ密码并没有被盗取.最近通过对一个QQ空间自动转发链接进行分析,发现该自动转发机制通过利用腾讯网站存在漏洞的页面,精心构造出利用代码获 ...
- QQ名片自动点赞
2017-01-23 简介:QQ名片自动点赞,1秒左右可点完1屏好友的赞,每个好友10个赞. 尺寸: 720*1280 DPI:320 宿主:3.1.2.10711 系统:Android v5.11 ...
- Java版 QQ空间自动登录无需拷贝cookie一天抓取30WQQ说说数据&流程分析
QQ空间说说抓取难度比较大,花了一个星期才研究清楚! 代码请移步到GitHub GitHub地址:https://github.com/20100507/Qzone [没有加入多线程,希望你可以参与进 ...
- Python案例之QQ空间自动登录程序实现
不多说,直接上干货! 工具选择: 电脑系统:win7,32 位,下面第二部安装SetupTools时注意系统版本要求: Python: 2.7.11, 相信只要是2.7的就可以实现: Seleniu ...
随机推荐
- 你真的了解Python自动化吗?这篇文章可以让你了解90%
人们为什么使用Python? 之所以选择Python的主要因素有以下几个方面: 软件质量:在很大程度上,Python更注重可读性.一致性和软件质量,从而与脚本语言世界中的其他工具区别开发.此外,Pyt ...
- NET 调用人脸识别算法
以前有个OpenCV 移植版EMCV可以用作图像识别等 https://github.com/emgucv/emgucv 现在有各种接口 比如虹软SDK https://ai.arcsoft.com ...
- NET 5 使用RabbitMQ以及Kafka区别
区别 1.应用场景方面RabbitMQ:用于实时的,对可靠性要求较高的消息传递上.kafka:用于处于活跃的流式数据,大数据量的数据处理上.2.架构模型方面producer,broker,consum ...
- 使用Ubuntu手动安装NextCloud
p.p1 { margin: 0; font: 11px Menlo; color: rgba(0, 0, 0, 1) } span.s1 { font-variant-ligatures: no-c ...
- 美团关于分布式ID实践方案
在复杂分布式系统中,往往需要对大量的数据和消息进行唯一标识.如在美团点评的金融.支付.餐饮.酒店.猫眼电影等产品的系统中,数据日渐增长,对数据分库分表后需要有一个唯一ID来标识一条数据或消息,数据库的 ...
- ROS开源小车TurtleBot3详情介绍(Burger)
您为什么要选择ROS开源智能小车 ROS(RobotOperating System,机器人操作系统)是目前世界上更主流更多人使用的的机器人开源操作系统.它可以提供操作系统应有的服务,包括硬件抽象,底 ...
- Adnc简介
Adnc是一个轻量级的.Net Core微服务(microservices)快速开发框架,同时也可以应用于单体架构系统的开发.框架基于JWT认证授权,包含基础的后台管理功能,代码简洁.易上手.学习成本 ...
- python 虾米停服了...用python爬取虾米最近播放的1000首歌
1. 虾米关服 在这里插入图片描述 用了5年多的音乐软件就这么说关就关了,确实让人心里不好受 ,虽然再去一个新的app里,让它们的算法熟悉你的喜好也不是很困难,可我还是习惯虾米的界面.虾米现在可以支持 ...
- Javascript函数闭包及案例详解
什么情况下会形成闭包,什么是闭包 闭包(Closure):函数和其周围的状态(词法环境)的引用捆绑在一起形成闭包 可以在另一个作用域中调用一个函数的内部函数并访问到该函数的作用域中的成员 下面来看一个 ...
- 风炫安全WEB安全学习第二十三节课 利用XSS获取COOKIE
风炫安全WEB安全学习第二十三节课 利用XSS获取COOKIE XSS如何利用 获取COOKIE 我们使用pikachu写的pkxss后台 使用方法: <img src="http:/ ...