旺旺商聊群发器批量,阿里旺旺私信群发脚本,淘宝商家卖家私信插件工具

简介: 使用Selenium模拟浏览器操作实现淘宝/阿里旺旺自动登录和私信发送支持从JSON文件加载消息模板和联系人列表

下载地址:https://www.pan38.com/share.php?code=pvvmX 提取码:1800

代码功能说明:

使用Selenium模拟浏览器操作实现淘宝/阿里旺旺自动登录和私信发送
支持从JSON文件加载消息模板和联系人列表
包含随机延迟机制避免被检测为自动化脚本
实现多级异常处理和重试机制提高稳定性
支持个性化消息模板,可插入联系人姓名等变量
提供详细的运行日志和统计信息
使用Chrome浏览器隐身模式避免cookie干扰

import time
import random
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException, TimeoutException

class TaobaoMassMessage:
def init(self):
self.driver = None
self.logged_in = False
self.message_templates = []
self.contact_list = []
self.config = {
'login_url': 'https://login.taobao.com/',
'message_url': 'https://msg.taobao.com/',
'wait_time': 15,
'delay_range': (3, 8),
'max_retries': 3
}

def init_driver(self):
    options = webdriver.ChromeOptions()
    options.add_argument('--disable-blink-features=AutomationControlled')
    options.add_experimental_option('excludeSwitches', ['enable-automation'])
    options.add_argument('--start-maximized')
    self.driver = webdriver.Chrome(options=options)
    self.driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")

def login(self, username, password):
    if not self.driver:
        self.init_driver()

    for attempt in range(self.config['max_retries']):
        try:
            self.driver.get(self.config['login_url'])
            WebDriverWait(self.driver, self.config['wait_time']).until(
                EC.presence_of_element_located((By.ID, 'fm-login-id'))
            )

            # 切换到账号密码登录
            switch_btn = self.driver.find_element(By.XPATH, '//*[@id="login"]/div[1]/i')
            switch_btn.click()

            # 输入用户名
            username_input = self.driver.find_element(By.ID, 'fm-login-id')
            username_input.clear()
            username_input.send_keys(username)

            # 输入密码
            password_input = self.driver.find_element(By.ID, 'fm-login-password')
            password_input.clear()
            password_input.send_keys(password)

            # 点击登录
            login_btn = self.driver.find_element(By.XPATH, '//*[@id="login-form"]/div[4]/button')
            login_btn.click()

            # 等待登录成功
            WebDriverWait(self.driver, self.config['wait_time']).until(
                lambda driver: 'taobao.com' in driver.current_url
            )
            self.logged_in = True
            print("登录成功")
            return True

        except Exception as e:
            print(f"登录尝试 {attempt + 1} 失败: {str(e)}")
            if attempt == self.config['max_retries'] - 1:
                print("达到最大重试次数,登录失败")
                return False
            time.sleep(5)
            continue

def load_message_templates(self, file_path):
    try:
        with open(file_path, 'r', encoding='utf-8') as f:
            self.message_templates = json.load(f)
        print(f"成功加载 {len(self.message_templates)} 条消息模板")
        return True
    except Exception as e:
        print(f"加载消息模板失败: {str(e)}")
        return False

def load_contact_list(self, file_path):
    try:
        with open(file_path, 'r', encoding='utf-8') as f:
            self.contact_list = json.load(f)
        print(f"成功加载 {len(self.contact_list)} 个联系人")
        return True
    except Exception as e:
        print(f"加载联系人列表失败: {str(e)}")
        return False

def random_delay(self):
    delay = random.uniform(*self.config['delay_range'])
    time.sleep(delay)

def send_single_message(self, contact, message):
    if not self.logged_in:
        print("请先登录")
        return False

    for attempt in range(self.config['max_retries']):
        try:
            # 打开消息页面
            self.driver.get(f"{self.config['message_url']}sendmsg.htm?toUserId={contact['user_id']}")

            # 等待消息框加载
            message_box = WebDriverWait(self.driver, self.config['wait_time']).until(
                EC.presence_of_element_located((By.ID, 'J_Message'))
            )

            # 清空可能存在的默认内容
            message_box.clear()
            self.random_delay()

            # 输入消息
            message_box.send_keys(message)
            self.random_delay()

            # 点击发送
            send_btn = WebDriverWait(self.driver, self.config['wait_time']).until(
                EC.element_to_be_clickable((By.ID, 'J_Send'))
            )
            send_btn.click()
            self.random_delay()

            print(f"已发送消息给 {contact['name']}")
            return True

        except Exception as e:
            print(f"发送消息给 {contact['name']} 失败 (尝试 {attempt + 1}): {str(e)}")
            if attempt == self.config['max_retries'] - 1:
                return False
            time.sleep(5)
            continue

def send_mass_messages(self):
    if not self.message_templates or not self.contact_list:
        print("请先加载消息模板和联系人列表")
        return False

    success_count = 0
    failure_count = 0

    for contact in self.contact_list:
        # 随机选择一条消息模板
        template = random.choice(self.message_templates)
        message = template['content'].format(name=contact['name'])

        if self.send_single_message(contact, message):
            success_count += 1
        else:
            failure_count += 1

        # 随机延迟,避免触发反爬
        self.random_delay()

    print(f"\n发送完成: 成功 {success_count} 条, 失败 {failure_count} 条")
    return True

def close(self):
    if self.driver:
        self.driver.quit()
        print("浏览器已关闭")

def main():
bot = TaobaoMassMessage()

try:
    # 加载配置
    if not bot.load_message_templates('message_templates.json'):
        return
    if not bot.load_contact_list('contact_list.json'):
        return

    # 登录
    username = input("请输入淘宝账号: ")
    password = input("请输入密码: ")
    if not bot.login(username, password):
        return

    # 开始发送
    print("\n开始批量发送消息...")
    bot.send_mass_messages()

except KeyboardInterrupt:
    print("\n用户中断操作")
except Exception as e:
    print(f"程序运行出错: {str(e)}")
finally:
    bot.close()

if name == "main":
main()

相关文章
|
API PHP 开发者
大麦网 API 接口商品详情信息 API
为了让更多用户了解到大麦网的商品详情,并能够方便地获取相关信息,大麦网推出了商品详情 API 接口。本文将介绍大麦网商品详情 API 接口的作用、使用方法和注意事项,帮助广大开发者更加方便地接入大麦网的产品。
|
前端开发 JavaScript Java
若依前后端部署之后验证码不显示
若依前后端部署之后验证码不显示
|
人工智能 JavaScript 前端开发
【前端|JS实战第1篇】使用JS来实现属于自己的贪吃蛇游戏!
【前端|JS实战第1篇】使用JS来实现属于自己的贪吃蛇游戏!
608 0
|
网络协议 网络架构
什么是BGP机房?3分钟全面了解BGP机房
购买服务器最常见的术语就是BGP机房,什么是BGP机房?BGP机房有什么特点?服务器百科网带你3分钟全面了解BGP机房: 什么是BGP机房? 在了解BGP机房之前服务器百科网带大家先了解下BGP,BGP是指边界网关协议(Border Gateway Protocol),BGP是运行于TCP上的一种自治系统(AS)的路由协议,是能够妥善处理不相关路由域间的多路连接的协议。
14588 2
|
12月前
淘宝商家卖家批量私信群发工具,阿里旺旺采集提取私信脚本插件无限制
这是一款专为网店运营人员设计的自动化私信工具,基于平台内部优化,稳定性高,已服务多届客户并经过多次迭代升级。通过模拟点击、输入话术等操作
|
10月前
|
监控 数据可视化 机器人
直播间自动发言机器人,直播场控机器人免费版,快手抖音小红书哔哩哔哩工具
核心控制器采用异步IO架构,支持同时处理弹幕监控、自动回复和数据统计 实现多平台适配层,通过配置驱动支持抖音/快手/小红书/哔哩哔哩的差异化处理
|
10月前
抖音批量养号工具,抖音小红书快手养号脚本,看广告刷视频插件工具
多平台支持:集成抖音、小红书、快手三大平台的自动化操作 模拟人类行为:包含随机鼠标移动
|
10月前
|
JSON 搜索推荐 机器人
直播间自动发言机器人,抖音快手小红书哔哩哔哩机器人, 自动评论app机器人打字弹幕脚本
多平台支持:整合抖音、哔哩哔哩等平台的自动化操作 智能评论生成:结合视频内容动态生成个性化评论
|
10月前
|
机器人 Windows
直播间自动发言机器人,抖音机器人评论脚本,直播间自动发言机器人
多线程架构实现弹幕监听和发送分离 支持特殊用户识别和定制回复
|
10月前
|
Android开发 Python
自动养手机权重脚本,抖音看广告刷金币脚本插件, 抖音自动养号脚本app
采用uiautomator2实现Android设备控制,比纯ADB命令更稳定 随机化操作参数包括:观看时长