雕虫小技之批量取消抖音关注

很精准

import cv2
import numpy as np
import pyautogui
import time

# 加载“关注”按钮的模板图像
follow_button_template = cv2.imread('dy3.png', 0)  # 替换为你的“关注”按钮截图

# 设置匹配阈值(根据实际情况调整)
threshold = 0.8
def scroll_down():
    pyautogui.scroll(-100)  # 向下滚动页面
    time.sleep(1)  # 等待页面加载
def find_and_click_button(template):
    # 截取当前屏幕
    screenshot = pyautogui.screenshot()
    screenshot = cv2.cvtColor(np.array(screenshot), cv2.COLOR_RGB2GRAY)

    # 使用模板匹配查找“关注”按钮
    result = cv2.matchTemplate(screenshot, template, cv2.TM_CCOEFF_NORMED)
    min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result)

    # 如果匹配度超过阈值,则认为找到了按钮
    if max_val >= threshold:
        # 获取按钮的中心位置
        h, w = template.shape
        button_center = (max_loc[0] + w // 2, max_loc[1] + h // 2)

        # 移动鼠标到按钮位置并点击
        pyautogui.moveTo(button_center[0], button_center[1], duration=0.5)
        pyautogui.click()
        print(f"找到并点击了按钮,位置: {button_center}")
        return True
    else:
        print("未找到按钮")
        return False

# 在主循环中加入滚动逻辑
def main():
    print("开始批量取消关注...")
    while True:
        if not find_and_click_button(follow_button_template):
            print("没有更多按钮可点击,尝试滚动页面...")
            scroll_down()
        else:
            time.sleep(1)  # 避免过快点击导致误操作

if __name__ == "__main__":
    main()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值