前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python批量取关微信公众号 – 学金融的文史哲小生

Python批量取关微信公众号 – 学金融的文史哲小生

作者头像
去海边整点薯条
发布2022-11-01 13:57:23
6160
发布2022-11-01 13:57:23
举报
文章被收录于专栏:数模计量

一、打开微信电脑版

二、找到通讯录页面

三、全屏通讯录页面

四、新建xxx.py的文件

1.复制如下内容,并运行程序

代码语言:javascript
复制
import win32api
import ctypes
import time
import random
rand_time=random.uniform(0,1)
# 和所有的公众号说再见,包括我自己的公众号!~
# 定义鼠标左侧单击函数
def left_press(x, y, button=1):
    buttonAction = 2 ** ((2 * button) - 1)
    win32api.mouse_event(buttonAction, x, y)
# 定义鼠标左侧单击释放函数
def left_release(x, y, button=1):
    buttonAction = 2 ** ((2 * button))
    win32api.mouse_event(buttonAction, x, y)    
# 定义鼠标右侧单击函数
def right_press(x, y, button=2):
    buttonAction = 2 ** ((2 * button) - 1)
    win32api.mouse_event(buttonAction, x, y)
# 定义鼠标右侧单击释放函数
def right_release(x, y, button=2):
    buttonAction = 2 ** ((2 * button))
    win32api.mouse_event(buttonAction, x, y)   
# 定义鼠标移动函数
def move(x, y):
    ctypes.windll.user32.SetCursorPos(x, y)
# 最小化程序运行的窗体,并且移动到LOGO的显示坐标位置
# (1180,15)程序运行的窗体坐标位置
# 移动到坐标
time.sleep(1)
move(x=1180,y=15)
# 休眠1s
time.sleep(rand_time)
# 点击
left_press(x=1180,y=15)
# 释放鼠标左键
left_release(x=1180,y=15)
for i in range(30):
    # (613,173)公众号LOGO的坐标位置
    time.sleep(rand_time)  
    move(613,120)
    right_press(613,120)
    right_release(613,120)
    # 左击“取消关注”
    time.sleep(rand_time)  
    move(633,185)
    left_press(633,185)
    left_release(633,185)
    # 点击确定
    time.sleep(rand_time)  
    move(700,430)
    left_press(700,430)
    left_release(700,430)

2.默认循环30次,也就是取消30个公众号。如果想要自定义个数,可以用这个代码

代码语言:javascript
复制
import win32api
import ctypes
import time
import random
numbers=input("请输入取消的公众号次数:")
rand_time=random.uniform(0,1)
# 和所有的公众号说再见,包括我自己的公众号!~
# 定义鼠标左侧单击函数
def left_press(x, y, button=1):
    buttonAction = 2 ** ((2 * button) - 1)
    win32api.mouse_event(buttonAction, x, y)
# 定义鼠标左侧单击释放函数
def left_release(x, y, button=1):
    buttonAction = 2 ** ((2 * button))
    win32api.mouse_event(buttonAction, x, y)    
# 定义鼠标右侧单击函数
def right_press(x, y, button=2):
    buttonAction = 2 ** ((2 * button) - 1)
    win32api.mouse_event(buttonAction, x, y)
# 定义鼠标右侧单击释放函数
def right_release(x, y, button=2):
    buttonAction = 2 ** ((2 * button))
    win32api.mouse_event(buttonAction, x, y)   
# 定义鼠标移动函数
def move(x, y):
    ctypes.windll.user32.SetCursorPos(x, y)
# 最小化程序运行的窗体,并且移动到LOGO的显示坐标位置
# (1180,15)程序运行的窗体坐标位置
# 移动到坐标
time.sleep(1)
move(x=1180,y=15)
# 休眠1s
time.sleep(rand_time)
# 点击
left_press(x=1180,y=15)
# 释放鼠标左键
left_release(x=1180,y=15)
for i in range(numbers):
    # (613,173)公众号LOGO的坐标位置
    time.sleep(rand_time)  
    move(613,120)
    right_press(613,120)
    right_release(613,120)
    # 左击“取消关注”
    time.sleep(rand_time)  
    move(633,185)
    left_press(633,185)
    left_release(633,185)
    # 点击确定
    time.sleep(rand_time)  
    move(700,430)
    left_press(700,430)
    left_release(700,430)

五、操作演示

https://img.caoyongzhuo.cn/gh/TonaSmith/picture/img/quxiaogongzhonghao.mp4

六、特别说明

1.我的电脑是1920x1080分辨率,所以上述的坐标也只对这个分辨率起作用 2.运行程序时,保证通讯录页面全屏且在VSCODE程序的下面 3.代码写的很烂,主要不是科班出身,还需要加倍努力!

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-11-03 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、打开微信电脑版
  • 二、找到通讯录页面
  • 三、全屏通讯录页面
  • 四、新建xxx.py的文件
  • 五、操作演示
  • 六、特别说明
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档