python实现快手美女颜值打分,高颜值的自动点赞关注


前言

快手现在很多人都在用,今天就用python写一个快手自动点赞+关注脚本,而且还能薅羊毛(一天2块钱的样子)。


提示:以下是本篇文章正文内容,下面案例可供参考

一、adb是什么?

Adb的全称为Android Debug Bridge,起到调试桥的作用,通过adb,可以让用户在电脑上控制Android设备,对手机进行全面操作。

作为一名开发者倒是常用到这个工具,借助adb工具,我们可以管理设备或手机模拟器的状态,还可以进行很多手机操作,如安装软件、卸载软件、系统升级、运行shell命令等等。

二、使用步骤

1.准备工作

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

1.引入库

代码如下(示例):

import os
import time
import random
import requests
import base64

2.控制滑动屏幕

代码如下(示例):

    while True:
        time_=random.randint(0, 3)#随机数
        os.system('adb shell input swipe 500 800 500 300')#滑动屏幕
        print(time_)
        time.sleep(time_)

2.利用百度api人脸识别代码

代码如下(示例):
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)

3.完整代码

代码如下(示例):

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是免费的,用起来也特别的方便,代码可以控制手机,也可以控制模拟器,具体自己再看吧,谢谢浏览。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值