快手现在很多人都在用,今天就用python写一个快手自动点赞+关注脚本,而且还能薅羊毛(一天2块钱的样子)。
提示:以下是本篇文章正文内容,下面案例可供参考
Adb的全称为Android Debug Bridge,起到调试桥的作用,通过adb,可以让用户在电脑上控制Android设备,对手机进行全面操作。
作为一名开发者倒是常用到这个工具,借助adb工具,我们可以管理设备或手机模拟器的状态,还可以进行很多手机操作,如安装软件、卸载软件、系统升级、运行shell命令等等。
1.点击下载adb工具,下载python(Python3.8.7)
2.安装所需要的库
pip install requests
pip install pybase64
3.百度API
百度API官网https://ai.baidu.com/?track=cp:aipinzhuan|pf:pc|pp:AIpingtai|pu:title|ci:|kw:10005792
代码如下(示例):
import os
import time
import random
import requests
import base64
代码如下(示例):
while True:
time_=random.randint(0, 3)#随机数
os.system('adb shell input swipe 500 800 500 300')#滑动屏幕
print(time_)
time.sleep(time_)
代码如下(示例):
access_token 30天之后需要重新生成一次,最后将获得的数据取出来。
params = {“image”: img, “image_type”: “BASE64”, “face_field”: “age,gender,beauty,emotion”}中 “face_field”后面跟的是参数
'''
人脸检测与属性分析
'''
os.system('adb -s emulator-5554 shell /system/bin/screencap -p /sdcard/xjj.png')
os.system('adb -s emulator-5554 pull /sdcard/xjj.png ')
time.sleep(3)
f = open('xjj.png', 'rb')
img = base64.b64encode(f.read())
request_url = "https://aip.baidubce.com/rest/2.0/face/v3/detect"
params = {"image": img, "image_type": "BASE64", "face_field": "age,gender,beauty,emotion"}
access_token = '24.9af64aac2931de46d8f44de0063823a8.2592000.1604039719.282335-22672928'
request_url = request_url + "?access_token=" + access_token
headers = {'content-type': 'application/json'}
response = requests.post(request_url, data=params, headers=headers)
if response:
data = response.json()
print(data)
代码如下(示例):
import os
import time
import random
import requests
import base64
#打开快手
# os.system('adb shell am start com.kuaishou.nebula')
def ks():
while True:
time_=random.randint(0, 3)
os.system('adb shell input swipe 500 800 500 300')#滑动屏幕
# os.system('adb -s emulator-5554 shell input swipe 500 800 500 300') # 滑动屏幕
print(time_)
time.sleep(time_)
'''
人脸检测与属性分析
'''
os.system('adb -s emulator-5554 shell /system/bin/screencap -p /sdcard/xjj.png')
os.system('adb -s emulator-5554 pull /sdcard/xjj.png ')
time.sleep(3)
f = open('xjj.png', 'rb')
img = base64.b64encode(f.read())
request_url = "https://aip.baidubce.com/rest/2.0/face/v3/detect"
params = {"image": img, "image_type": "BASE64", "face_field": "age,gender,beauty,emotion"}
access_token = '24.9af64aac2931de46d8f44de0063823a8.2592000.1604039719.282335-22672928'
request_url = request_url + "?access_token=" + access_token
headers = {'content-type': 'application/json'}
response = requests.post(request_url, data=params, headers=headers)
if response:
try:
data = response.json()
# print(data)
data1 = data['result']
data2 = data1['face_list']
data3 = data2[0]
age = data3['age']
yanzhi = data3['beauty']
# print(yanzhi)
xingbie = data3['gender']
gender = xingbie['type']
if gender == 'female':
print('个人资料\n#####################\n性别:女' + '\n年龄:', age, '\n颜值', yanzhi,'\n###################')
if age < 30 and gender == 'female':
print('是女的,并且很年轻,而且颜值还行,高达',yanzhi,'\n爱了爱了,帮你点赞加关注')
time.sleep(1)
#点赞
os.system('adb -s emulator-5554 shell input tap 195 1378')
#关注
os.system('adb shell input swipe 500 300 100 300')
time.sleep(1)
os.system('adb -s emulator-5554 shell input tap 432 698')
time.sleep(1)
print('已关注')
time.sleep(3)
os.system('adb shell input keyevent 4')
os.system('adb shell input keyevent 4')
os.system("cls")
time.sleep(2)
else:
print('男的不看,跳过')
time.sleep(3)
os.system("cls")
except:
print('啥也不是')
os.system("cls")
time.sleep(2)
if __name__ == '__main__':
ks()
百度API是免费的,用起来也特别的方便,代码可以控制手机,也可以控制模拟器,具体自己再看吧,谢谢浏览。