手机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 ...
随机推荐
- Sqlmap 学习笔记1:sqlmap参数
SQLMP参数分析 1 目录 1.Target Options 2.Requests Options 3.Injection Options 4.Detection Options 5.Techniq ...
- 从零到一快速搭建个人博客网站(域名自动跳转www,二级域名使用)(二)
前言 本篇文章是对上篇文章从零到一快速搭建个人博客网站(域名备案 + https免费证书)(一)的完善,比如域名自动跳转www.二级域名使用等. 域名自动跳转www 这里对上篇域名访问进行优化,首先支 ...
- 第十章 Seata--分布式事务
承接上篇 ,终于我们迎来了最后一章 第九章 Nacos Config–服务配置,第十章 Seata–分布式事务,感谢你能学习到这 !废话不多说,撸码 10.1 分布式事务基础 10.1.1 事务 事务 ...
- Python 学习笔记(上)
Python 学习笔记(上) 这份笔记是我在系统地学习python时记录的,它不能算是一份完整的参考,但里面大都是我觉得比较重要的地方. 目录 Python 学习笔记(上) 基础知识 基本输入输出 模 ...
- Python写一个对象,让它自己能够迭代
仿写range()对象,对象是可迭代的: 1 #!usr/bin/env python3 2 # -*- coding=utf-8 -*- 3 4 class myRange(): 5 #初始化,也叫 ...
- 理解Tomcat工作原理
WEB服务器 只要Web上的Server都叫Web Server,但是大家分工不同,解决的问题也不同,所以根据Web Server提供的功能,每个Web Server的名字也会不一样. 按功能分类,W ...
- Spring Data JPA简介 Spring Data JPA特点
Spring Data JPA 是Spring基于ORM框架.JPA规范的基础上封装的一套JPA 应用框架,底层使用了Hibernate 的JPA技术实现,可使开发者用极简的代码即可实现对数据的访问和 ...
- 任意文件上传——tcp
package chaoba; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; ...
- spark常用提交任务的基本的参数配置
#!/bin/bash #队列名 根据yarn的队列提交 realtime_queue=root #提交的任务名 my_job_name="OrderQZ" spark-shell ...
- Task1:知识图谱介绍(1天)
一.知识图谱简介 "知识图谱本质上是语义网络(Semantic Network)的知识库".但这有点抽象,所以换个角度,从实际应用的角度出发其实可以简单地把知识图谱理解成多关系图( ...