下载地址:http://m.pan38.com/download.php?code=ENROLN 提取码:3881
主要功能说明:
采用uiautomator2实现Android设备控制,比纯ADB命令更稳定
随机化操作参数包括:观看时长、滑动间隔、点击位置等,模拟人类行为降低封号风险
养号功能包含:随机点赞(20%概率)、评论(5%概率)、关注(10%概率)和关键词搜
广告检测机制自动处理弹窗,可配置点击概率(默认30%)
异常处理模块在出错时自动重启应用,保证长时间运行
import os
import time
import random
import uiautomator2 as u2
from PIL import Image
import numpy as np
class DouyinAutomator:
def init(self, device_id=None):
self.d = u2.connect(device_id) if device_id else u2.connect()
self.config = {
'watch_time_range': [8, 15], # 观看时长范围(秒)
'swipe_delay_range': [5, 10], # 滑动间隔(秒)
'ad_click_prob': 0.3, # 广告点击概率
'max_runtime': 3600, # 最大运行时长(秒)
'daily_tasks': { # 养号任务配置
'like_prob': 0.2,
'comment_prob': 0.05,
'follow_prob': 0.1,
'search_keywords': ['美食','旅游','科技']
}
}
def start_app(self):
"""启动抖音极速版并进入金币页面"""
self.d.app_start('com.ss.android.ugc.aweme.lite')
time.sleep(8)
# 点击金币入口
self.d.click(527, 2316)
time.sleep(5)
# 进入看广告赚金币
self.d.click(834, 828)
time.sleep(3)
def random_swipe(self):
"""模拟真人滑动"""
width, height = self.d.window_size()
x1 = random.randint(width//4, width*3//4)
y1 = random.randint(height//2, height*3//4)
x2 = random.randint(width//4, width*3//4)
y2 = random.randint(height//4, height//2)
duration = random.uniform(0.3, 1.0)
self.d.swipe(x1, y1, x2, y2, duration)
def watch_video(self):
"""观看视频并处理广告"""
watch_time = random.randint(*self.config['watch_time_range'])
print(f'观看{watch_time}秒')
# 随机点赞/评论
if random.random() < self.config['daily_tasks']['like_prob']:
self.d.click(900, 1800) # 点赞位置
time.sleep(0.5)
if random.random() < self.config['daily_tasks']['comment_prob']:
self.d.click(150, 1800) # 评论入口
time.sleep(1)
self.d.send_keys("不错的内容!")
self.d.click(800, 1300) # 发送按钮
time.sleep(2)
time.sleep(watch_time)
# 检测广告弹窗
if self.d(textContains='立即下载').exists:
if random.random() < self.config['ad_click_prob']:
self.d(textContains='立即下载').click()
time.sleep(3)
self.d.press('back')
else:
self.d(text='关闭').click()
def daily_tasks(self):
"""执行养号任务"""
# 随机搜索关键词
if random.random() < 0.5:
keyword = random.choice(self.config['daily_tasks']['search_keywords'])
self.d(resourceId="com.ss.android.ugc.aweme.lite:id/et_search_kw").set_text(keyword)
self.d(resourceId="com.ss.android.ugc.aweme.lite:id/search_icon").click()
time.sleep(5)
self.random_swipe()
time.sleep(3)
# 随机关注
if random.random() < self.config['daily_tasks']['follow_prob']:
self.d.click(750, 1800) # 关注按钮位置
time.sleep(1)
def run(self):
start_time = time.time()
self.start_app()
while time.time() - start_time < self.config['max_runtime']:
try:
self.watch_video()
self.daily_tasks() if random.random() < 0.3 else None
self.random_swipe()
delay = random.randint(*self.config['swipe_delay_range'])
time.sleep(delay)
# 每10分钟随机返回首页
if random.random() < 0.1:
self.d.press('back')
time.sleep(2)
self.start_app()
except Exception as e:
print(f'发生异常: {e}')
self.d.app_stop('com.ss.android.ugc.aweme.lite')
time.sleep(5)
self.start_app()
if name == 'main':
automator = DouyinAutomator()
automator.run()