首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >一键qq群批量加好友软件,QQ一键批量添加好友,QQ自动加好友工具【python】

一键qq群批量加好友软件,QQ一键批量添加好友,QQ自动加好友工具【python】

原创
作者头像
用户11744395
发布2025-07-17 09:43:08
发布2025-07-17 09:43:08
2830
举报

下载地址:https://www.pan38.com/dow/share.php?code=JCnzE 提取密码:1130

这个代码使用了Selenium自动化测试工具模拟浏览器操作,实现了从指定QQ群批量添加好友的功能。代码包含登录QQ、定位群成员、发送好友申请等完整流程。使用时需要安装Selenium和对应浏览器驱动,并修改QQ账号和群号参数。

请注意:实际使用时可能会遇到验证码、操作频率限制等问题,且频繁的自动化操作可能导致账号异常。建议仅用于学习研究目的,控制操作频率,避免对他人造成骚扰。

代码语言:txt
复制

import time
import random
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class QQAutoAdder:
    def __init__(self):
        self.chrome_options = Options()
        self.chrome_options.add_argument("--disable-notifications")
        self.chrome_options.add_argument("--disable-infobars")
        self.driver = webdriver.Chrome(options=self.chrome_options)
        self.wait = WebDriverWait(self.driver, 20)
        
    def login_qq(self, qq_number, qq_password):
        print("正在登录QQ...")
        self.driver.get("https://qzone.qq.com/")
        self.driver.switch_to.frame("login_frame")
        
        # 切换到账号密码登录
        self.wait.until(EC.element_to_be_clickable((By.ID, "switcher_plogin"))).click()
        
        # 输入账号密码
        self.wait.until(EC.presence_of_element_located((By.ID, "u"))).send_keys(qq_number)
        self.driver.find_element(By.ID, "p").send_keys(qq_password)
        
        # 点击登录
        self.driver.find_element(By.ID, "login_button").click()
        time.sleep(5)
        
    def add_friends_from_group(self, group_number, max_add=10):
        print(f"正在从群{group_number}添加好友...")
        self.driver.get(f"https://qun.qq.com/member.html#gid={group_number}")
        time.sleep(5)
        
        # 获取成员列表
        members = self.wait.until(EC.presence_of_all_elements_located(
            (By.CSS_SELECTOR, ".member-list .member-item")))
        
        added_count = 0
        for i, member in enumerate(members[:max_add]):
            try:
                # 点击成员头像
                avatar = member.find_element(By.CSS_SELECTOR, ".avatar")
                avatar.click()
                time.sleep(1)
                
                # 点击加好友按钮
                add_btn = self.wait.until(EC.element_to_be_clickable(
                    (By.CSS_SELECTOR, ".op-add-friend")))
                add_btn.click()
                time.sleep(1)
                
                # 填写验证信息
                verify_input = self.wait.until(EC.presence_of_element_located(
                    (By.CSS_SELECTOR, "textarea.verify-msg")))
                verify_input.clear()
                verify_input.send_keys("你好,交个朋友吧!")
                time.sleep(1)
                
                # 提交申请
                submit_btn = self.driver.find_element(By.CSS_SELECTOR, ".btn-submit")
                submit_btn.click()
                time.sleep(random.uniform(2, 5))
                
                added_count += 1
                print(f"已发送好友申请给第{i+1}个成员")
                
            except Exception as e:
                print(f"添加第{i+1}个成员时出错: {str(e)}")
                continue
                
        print(f"已完成,共发送{added_count}个好友申请")
        
    def close(self):
        self.driver.quit()

if __name__ == "__main__":
    bot = QQAutoAdder()
    try:
        bot.login_qq("你的QQ号", "你的QQ密码")
        bot.add_friends_from_group("群号", max_add=20)
    finally:
        bot.close()

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

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

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

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

评论
作者已关闭评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档