手机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实现 -个人公众号搭建-被动回复消息建模(14.3.2)
@ 目录 1.阅读官方文档 2.思考 关于作者 1.阅读官方文档 点击进入微信官方开发者文档 接收普通消息 文本消息 图片消息 语言消息 视频消息 小视频消息 地理位置消息 链接消息 接收事件消息 关 ...
- 持久层之 MyBatis: 第二篇 :动态SQL And多表查询
MyBatis入门到精通 完整CRUD UserDaoImpl 编写UserDao对应的UserDaoMapper.xml 添加UserDao的测试用例 编写UserDao的测试用例 解决数据库字段名 ...
- Linux-centos-64bit安装MySQL
1.下载mysql安装包到 /usr/local/soft [root@VM_0_9_centos ~]# cd /usr/local/soft[root@VM_0_9_centos soft]# w ...
- RHCE <复习RHSCA>
什么是shell? shell是你(用户)和Linux(或者更准确的说,是你和Linux内核)之间的接口程序,你在提示符下输入的每个命令都由shell先解释然后传给Linux内核. bash 是大多数 ...
- C# 锁与死锁
什么是死锁: 所谓死锁,是指多个进程在运行过程中因争夺资源而造成的一种僵局,当进程处于这种僵持状态时,若无外力作用,它们都将无法再向前推进. 因此我们举个例子来描述,如果此时有一个线程A,按照先锁a再 ...
- MySQL忘记密码了怎么解决
前言:在不考虑到原来用户对关联数据库的授权问题的情况下,有以下三种思路解决 #1.登录状态下修改 说明:在登录状态的话,直接使用命令修改密码就行了 mysql> use mysql; mysql ...
- WPF 中的相关样式
<Image Name="icon" Width="40" Height="40" Source="/Resources/ ...
- 在 xunit 测试项目中使用依赖注入
在 xunit 测试项目中使用依赖注入 Intro 之前写过几篇 xunit 依赖注入的文章,今天这篇文章将结合我在 .NET Conf 上的分享,更加系统的分享一下在测试中的应用案例. 之所以想分享 ...
- OpenResty 简介
OpenResty 简介 OpenResty 是一个基于 Nginx 与 Lua 的高性能 Web 平台.我们知道开发 Nginx 的模块需要用 C 语言,同时还要熟悉它的源码,成本和门槛比较高.国人 ...
- 自定义ClassLoader的使用
1 import java.io.ByteArrayOutputStream; 2 import java.io.File; 3 import java.io.FileInputStream; 4 i ...