python實現抖音自動關注


前提:使用之前需要對抖音關注頁面進行截圖放在當前目錄下

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)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM