额 看了 https://www.52pojie.cn/thread-1202580-6-1.html
这个兄弟的脚本 离到手可用好像有点远 所以简单的简化了一下
import os
import cv2
import time
import random
from PIL import Image
import numpy
def screen():
os.system('adb shell screencap -p /sdcard/screen.png')
os.system('adb pull /sdcard/screen.png')
def findImg(target, template):
print('匹配图片')
target = cv2.imread(target)
template = cv2.imread(template)
theight, twidth = template.shape[:2]
result = cv2.matchTemplate(target, template, cv2.TM_SQDIFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)
cv2.rectangle(target, min_loc, (min_loc[0] + twidth, min_loc[1] + theight), (0, 0, 225), 2)
strmin_val = str(min_val)
temp_loc = min_loc
other_loc = min_loc
numOfloc = 1
threshold = 0.01
loc = numpy.where(result < threshold)
if loc:
for other_loc in zip(*loc[::-1]):
yield other_loc
else:
return False
if __name__ == '__main__':
sj = random.uniform(20, 40)
for i in range(100):
screen()
print('截屏某用户的粉丝列表')
xy = findImg('screen.png','template.png')
for index,d in enumerate(xy):
print('找到第%s个:%s'%(str(index+1),d))
os.system('adb shell input tap %s %s'%(d[0]+100,d[1]+30))
time.sleep(sj)
os.system('adb shell input swipe 548 1500 540 225 511')
print('正在翻页。。。')
time.sleep(sj)
简单说一下吧,首先,你要把adb配置好,这个去查一下相关资料,用模拟器或者安卓手机都行。
adb
像这样 只要adb devices 出现就说明正常工作了 我这里链接的是夜神模拟器
然后打开手机或者模拟器上的抖音 转到粉丝详情页
然后运行我们的代码,原理就是在这个详情页里面找关注按钮这个图,我用的这个,你们也可以自己截取,当然名字要改成template.png(或者改代码里图片名字)
找到按钮 关注 关注 关注。。。 然后下一页 关注 关注 关注
这么太快 所以我延时设置的比较长
```
sj = random.uniform(20, 40)
```
可以看情况修改 基本就是这样了 第一次发帖 希望格式没乱 |