前提:使用之前需要对抖音关注页面进行截图放在当前目录下
import os from PIL import Image # pip install pillow import sys import time def Screen_cap(): #截屏 os.system("adb shell screencap -p /sdcard/screen.png") #保存图片 os.system('adb pull /sdcard/screen.png') #横坐标不变,纵坐标变 852 #长度 2340 852一直去遍历2340 254,52,92 # 评论的内容 设置一个列表 打广告之类的哈(要做停留,模拟停留) def Gety_position(): y_list = [] image = Image.open('screen.png') #得到当前目录下的文件 for i in [852]: for y in range(2340): if image.getpixel((i,y)) == (254,52,92,255): #RGBA 表示三基色和透明度 print(y) y_list.append(y) return y_list for n in range(sys.maxsize): #截屏 Screen_cap() #得到y坐标 y_position = Gety_position() #模拟点击 for y in y_position: os.system('adb shell input tap 852 {}'.format(y)) time.sleep(1) print('正在关注。。。。。。') #翻页操作(根据手机的分辨率来设置) os.system('adb shell input swipe 540 2000 540 800') time.sleep(1)