Full Code of xxiaomuma/tauren-scritpt for AI

main 5a142d8144b4 cached
9 files
11.5 KB
2.9k tokens
22 symbols
1 requests
Download .txt
Repository: xxiaomuma/tauren-scritpt
Branch: main
Commit: 5a142d8144b4
Files: 9
Total size: 11.5 KB

Directory structure:
gitextract_8jdzgpga/

├── .gitignore
├── README.md
├── douyin/
│   └── douyin.py
├── douyin.text
├── load/
│   └── load.py
├── main.py
├── match_comment.text
├── match_video.text
└── operation/
    └── operation_douyin.py

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
.idea/


================================================
FILE: README.md
================================================
#### <center> TAUREN-SCRIPT </center>
###### 1.项目结构
```
tauren-script
    |———— douyin    抖音操作
    |———— load      加载相关
    |———— operation 操作相关
    |——— main
```
- Helium 是一个自动化库,主要用于网页自动化任务。在 Python 中安装 Helium 可以通过 pip 命令来完成。打开终端或命令提示符,然后输入以下命令:
    ```
    pip install helium
    ```
  如果你在使用 Python 3.x 版本,可能需要使用 pip3 命令:
    ```
    pip3 install helium
    ```
  [谷歌驱动下载](https://googlechromelabs.github.io/chrome-for-testing)


================================================
FILE: douyin/douyin.py
================================================
import time

from helium import *

from load.load import Load as file_load
from operation.operation_douyin import Operation

"""
 1. 用户作品针对性点赞收藏评论
 2. 视频点赞收藏评论
"""


class Douyin:

    def __init__(self, target_file_name, match_video_file_name, match_comment_file_name):
        self.is_login = False
        self.operate = Operation()
        self.link_items = file_load.load(target_file_name)
        self.match_video_items = file_load.load(match_video_file_name)
        self.match_comment_item_map = file_load.load_map(match_comment_file_name)

    def login(self):
        start_chrome('www.douyin.com')
        wait_until(Text('登录后免费畅享高清视频').exists)
        while True:
            exist = Text("登录后免费畅享高清视频").exists()
            if not exist:
                self.is_login = True
                print("登录成功")
                break
            else:
                time.sleep(3)
        time.sleep(6)
        press(DOWN)

    def search_account(self, operation_num):
        for link in self.link_items:
            print("正在处理: %s" % link)
            go_to(link)
            time.sleep(1)
            # 关注
            self.operate.user_click_follow()
            self.operate.user_video_comment(operation_num, self.match_video_items, self.match_comment_item_map)
            print("已完成")

    def search_video(self, operation_num):
        for link in self.link_items:
            print("正在处理: %s" % link)
            go_to(link)
            time.sleep(1)
            if operation_num == "1":
                # 点赞
                self.operate.video_click_like()
                # 评论
                self.operate.video_comment(self.match_comment_item_map)
            elif operation_num == "2":
                # 评论区评论+点赞
                self.operate.video_discuss_comment(self.match_comment_item_map)
        print("已完成")


================================================
FILE: douyin.text
================================================
https://www.douyin.com/user/MS4wLjABAAAAr4th9JQgdvrTJ7dxbg__xoDjSu5kS3JwV7C-nW48lm0

================================================
FILE: load/load.py
================================================
"""
  读取文件
"""
import os


class Load:

    @staticmethod
    def load(file_name):
        dir = os.getcwd()
        file_path = dir + "\\" + file_name
        print("读取文件信息: " + file_path)
        link_items = []
        with open(file_path, 'r', encoding="utf-8") as file:
            for line in file:
                link_items.append(line.strip())
        return link_items

    @staticmethod
    def load_map(file_name):
        dir = os.getcwd()
        file_path = dir + "\\" + file_name
        print("读取文件信息: " + file_path)
        link_item_map = {}
        with open(file_path, 'r', encoding="utf-8") as file:
            for line in file:
                line_items = line.strip().split(">")
                link_item_map[line_items[0]] = line_items[1]
        return link_item_map


================================================
FILE: main.py
================================================
from douyin.douyin import Douyin

dou_yin = Douyin("douyin.text", "match_video.text", "match_comment.text")


def select_platform():
    while True:
        print("平台:")
        print("1.抖音")
        print("2.快手")
        print("3.知乎")
        platform_num = input("请选择平台:")
        if platform_num == "1":
            dou_yin.login()
            select_douyin_function()
        elif platform_num == "2":
            print("建设中...")
        elif platform_num == "3":
            print("建设中...")
        else:
            print("输入有误")


def select_douyin_function():
    while True:
        print("抖音功能:")
        print("1.账户链接")
        print("2.视频链接")
        print("3.返回上一级")
        function_num = input("请选择抖音功能:")
        if function_num == "1" or function_num == "2":
            select_douyin_operation(function_num)
        elif function_num == "3":
            select_platform()
        else:
            print("输入有误")


def select_douyin_operation(function_num):
    while True:
        print("抖音操作:")
        print("1.简单评论模式")
        print("2.评论区评论模式")
        print("3.返回上一级")
        operation_num = input("请选择抖音操作:")
        if operation_num == "1" or operation_num == "2":
            while True:
                if not dou_yin.is_login:
                    print("请先登录...")
                    continue
                break
            if function_num == "1":
                dou_yin.search_account(operation_num)
            elif function_num == "2":
                dou_yin.search_video(operation_num)
        elif operation_num == "3":
            select_douyin_function()
        else:
            print("输入有误")

select_platform()


================================================
FILE: match_comment.text
================================================
泰山>哈哈哈,笑死
1231>1231

================================================
FILE: match_video.text
================================================
泰山

================================================
FILE: operation/operation_douyin.py
================================================
import time
from helium import *


class Operation:

    #
    # 用户作品评论
    #
    def user_video_comment(self, operation_num, match_video_items, match_comment_item_map):
        total_user_video_count = int(find_all(S("//span[@data-e2e='user-tab-count']"))[0].web_element.text)
        if total_user_video_count > 0:
            while True:
                user_video_label_items = find_all(S("//div[@data-e2e='user-post-list']/ul[@data-e2e='scroll-list']/li"))
                user_video_label_item_count = len(user_video_label_items)
                if total_user_video_count == 0 or user_video_label_item_count <= 0:
                    break
                self._handle_user_video_comment(operation_num, user_video_label_items, match_video_items, match_comment_item_map)
                hover(user_video_label_items[user_video_label_item_count].web_element)
        print("评论成功")

    #
    # 视频评论
    #
    def video_comment(self, match_comment_item_map):
        time.sleep(3)
        video_desc_label_items = find_all(S("//div[@data-e2e='video-desc']"))
        if len(video_desc_label_items) > 0 and len(match_comment_item_map.keys()) > 0:
            video_desc = video_desc_label_items[0].web_element.text
            match_comment_text = self._match_comment(video_desc, match_comment_item_map)
            if len(match_comment_text) > 0:
                press("x")
                time.sleep(1)
                write(match_comment_text)
                press(ENTER)
        print("评论成功")

    #
    # 视频评论区评论
    #
    def video_discuss_comment(self, match_comment_item_map):
        time.sleep(3)
        press("x")
        total_video_comment_count = 0
        video_comment_count_label_items = find_all(S('.comment-header-inner-container'))
        if len(video_comment_count_label_items) > 0:
            # '大家都在搜:泰山爬到山顶需要几小时全部评论(28710)'
            video_comment_count_text = video_comment_count_label_items[0].web_element.text
            total_video_comment_count = self._get_comment_total_count(video_comment_count_text)
        # 20初始化
        comment_class = ""
        comment_context_class = ""
        while True:
            time.sleep(3)
            video_comment_label_items = find_all(S("//div[@data-e2e='comment-item']"))
            video_comment_label_item_count = len(video_comment_label_items)
            if total_video_comment_count == 0 or video_comment_label_item_count <= 0:
                break
            if len(comment_class) <= 0 or len(comment_context_class) <= 0:
                elect_video_comment_label_item = video_comment_label_items[0]
                # 获取内容class
                comment_class = elect_video_comment_label_item.web_element.get_attribute("class")
                print("获取内容class:", comment_class)
                # 获取评论class
                elect_video_comment_context_label_items = find_all(S("." + comment_class + " > div > div > div"))
                comment_context_class = elect_video_comment_context_label_items[1].web_element.get_attribute("class")
                print("获取评论class:", comment_context_class)
            self._handle_video_discuss_comment(video_comment_label_item_count,
                                               comment_class, comment_context_class,
                                               match_comment_item_map)
            # 悬浮
            hover(video_comment_label_items[video_comment_label_item_count].web_element)
        self.video_comment(match_comment_item_map)

    #
    # 处理用户作品评论
    #
    def _handle_user_video_comment(self, operation_num, user_video_label_items, match_video_items, match_comment_item_map):
        handle_count = len(user_video_label_items)
        for index in range(handle_count):
            try:
                time.sleep(3)
                user_video_label_item = user_video_label_items[index].web_element
                user_video_text = user_video_label_item.text
                is_match_video = self._match_video(user_video_text, match_video_items)
                if is_match_video:
                    print("正在处理作品:", user_video_text)
                    user_video_label_item.click()
                    time.sleep(3)
                    if operation_num == "1":
                        self.video_comment(match_comment_item_map)
                    else:
                        self.video_discuss_comment(match_comment_item_map)
                    find_all(S(".isDark"))[0].web_element.click()
            except IndexError as e:
                print("err: {e}")
                continue

    #
    # 处理视频评论区评论
    #
    def _handle_video_discuss_comment(self, handle_count, comment_class, comment_context_class, match_comment_item_map):
        for index in range(handle_count):
            try:
                video_comment_context_label_item = find_all(S("." + comment_class + " ." + comment_context_class))[
                    index]
                comment_text = video_comment_context_label_item.web_element.text
                match_comment_text = self._match_comment(comment_text, match_comment_item_map)
                print("正在处理:", comment_text)
                if len(match_comment_text) > 0:
                    response_label_items = find_all(S("." + comment_class + " .dy-tip-container"))
                    click(response_label_items[index].web_element)
                    click("留下你的精彩评论吧")
                    write(match_comment_text)
                    press(ENTER)
            except IndexError as e:
                print("err: {e}")
                continue

    #
    # 视频点赞
    #
    @staticmethod
    def video_click_like():
        time.sleep(3)
        like_label_items = find_all(S("//div[@data-e2e-state='video-player-no-digged']"))
        if len(like_label_items) > 0:
            press("z")
            print("点赞成功")
        else:
            print("该视频已经点赞啦")

    #
    # 用户关注
    #
    @staticmethod
    def user_click_follow():
        time.sleep(3)
        follow_exist = Text("关注").exists()
        if not follow_exist:
            follow_exist = Text("回关").exists()
            if not follow_exist:
                print("该用户已关注啦")
            else:
                click("回关")
                print("回关成功")
        else:
            click("关注")
            print("关注成功")

    #
    # 匹配消息
    #
    @staticmethod
    def _match_comment(video_desc, match_comment_item_map):
        for key, value in match_comment_item_map.items():
            if key in video_desc:
                return value
        return ""

    #
    # 匹配视频
    #
    @staticmethod
    def _match_video(video_desc, match_video_items):
        for match_video_item in match_video_items:
            if match_video_item in video_desc:
                return True
        return False

    #
    # 获取内容评论总条数
    #
    @staticmethod
    def _get_comment_total_count(video_comment_count_text):
        return video_comment_count_text[video_comment_count_text.find("(") + 1:video_comment_count_text.find(")")]


Download .txt
gitextract_8jdzgpga/

├── .gitignore
├── README.md
├── douyin/
│   └── douyin.py
├── douyin.text
├── load/
│   └── load.py
├── main.py
├── match_comment.text
├── match_video.text
└── operation/
    └── operation_douyin.py
Download .txt
SYMBOL INDEX (22 symbols across 4 files)

FILE: douyin/douyin.py
  class Douyin (line 14) | class Douyin:
    method __init__ (line 16) | def __init__(self, target_file_name, match_video_file_name, match_comm...
    method login (line 23) | def login(self):
    method search_account (line 37) | def search_account(self, operation_num):
    method search_video (line 47) | def search_video(self, operation_num):

FILE: load/load.py
  class Load (line 7) | class Load:
    method load (line 10) | def load(file_name):
    method load_map (line 21) | def load_map(file_name):

FILE: main.py
  function select_platform (line 6) | def select_platform():
  function select_douyin_function (line 24) | def select_douyin_function():
  function select_douyin_operation (line 39) | def select_douyin_operation(function_num):

FILE: operation/operation_douyin.py
  class Operation (line 5) | class Operation:
    method user_video_comment (line 10) | def user_video_comment(self, operation_num, match_video_items, match_c...
    method video_comment (line 25) | def video_comment(self, match_comment_item_map):
    method video_discuss_comment (line 41) | def video_discuss_comment(self, match_comment_item_map):
    method _handle_user_video_comment (line 78) | def _handle_user_video_comment(self, operation_num, user_video_label_i...
    method _handle_video_discuss_comment (line 102) | def _handle_video_discuss_comment(self, handle_count, comment_class, c...
    method video_click_like (line 124) | def video_click_like():
    method user_click_follow (line 137) | def user_click_follow():
    method _match_comment (line 155) | def _match_comment(video_desc, match_comment_item_map):
    method _match_video (line 165) | def _match_video(video_desc, match_video_items):
    method _get_comment_total_count (line 175) | def _get_comment_total_count(video_comment_count_text):
Condensed preview — 9 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (14K chars).
[
  {
    "path": ".gitignore",
    "chars": 7,
    "preview": ".idea/\n"
  },
  {
    "path": "README.md",
    "chars": 432,
    "preview": "#### <center> TAUREN-SCRIPT </center>\n###### 1.项目结构\n```\ntauren-script\n    |———— douyin    抖音操作\n    |———— load      加载相关\n"
  },
  {
    "path": "douyin/douyin.py",
    "chars": 1833,
    "preview": "import time\n\nfrom helium import *\n\nfrom load.load import Load as file_load\nfrom operation.operation_douyin import Operat"
  },
  {
    "path": "douyin.text",
    "chars": 83,
    "preview": "https://www.douyin.com/user/MS4wLjABAAAAr4th9JQgdvrTJ7dxbg__xoDjSu5kS3JwV7C-nW48lm0"
  },
  {
    "path": "load/load.py",
    "chars": 795,
    "preview": "\"\"\"\n  读取文件\n\"\"\"\nimport os\n\n\nclass Load:\n\n    @staticmethod\n    def load(file_name):\n        dir = os.getcwd()\n        fil"
  },
  {
    "path": "main.py",
    "chars": 1655,
    "preview": "from douyin.douyin import Douyin\n\ndou_yin = Douyin(\"douyin.text\", \"match_video.text\", \"match_comment.text\")\n\n\ndef select"
  },
  {
    "path": "match_comment.text",
    "chars": 19,
    "preview": "泰山>哈哈哈,笑死\n1231>1231"
  },
  {
    "path": "match_video.text",
    "chars": 2,
    "preview": "泰山"
  },
  {
    "path": "operation/operation_douyin.py",
    "chars": 6984,
    "preview": "import time\nfrom helium import *\n\n\nclass Operation:\n\n    #\n    # 用户作品评论\n    #\n    def user_video_comment(self, operation"
  }
]

About this extraction

This page contains the full source code of the xxiaomuma/tauren-scritpt GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 9 files (11.5 KB), approximately 2.9k tokens, and a symbol index with 22 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!