reddit-browser-automation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Reddit/Postmill Browser Automation Skill

Reddit/Postmill 浏览器自动化Skill

This skill is based on Playwright MCP tools, providing automation capabilities for Reddit-like forum platforms (Postmill).
本Skill基于Playwright MCP工具,为类Reddit论坛平台(Postmill)提供自动化能力。

Core Concepts

核心概念

In forum automation, we distinguish two types of operations:
  1. Skill: Meaningful combinations of multiple tool calls, encapsulated as independent Python scripts
  2. Basic Tools: Single function calls used for atomic operations.

在论坛自动化中,我们将操作分为两类:
  1. Skill:由多个工具调用组合而成的有意义操作,封装为独立的Python脚本
  2. 基础工具:用于原子操作的单一函数调用。

I. Skills

一、预设Skill

1. Sign Up

1. 注册账号

Use Cases:
  • Create a new account on the forum after cilcing "Sign up" button
  • Register with specific username and password
Usage:
bash
undefined
适用场景
  • 点击“Sign up”按钮后在论坛创建新账号
  • 使用指定用户名和密码完成注册
使用方法
bash
undefined

Usage:

Usage:

python sign_up.py <username> <password> <username_ref> <password_ref> <password_repeat_ref> <submit_ref>

python sign_up.py <username> <password> <username_ref> <password_ref> <password_repeat_ref> <submit_ref>

Example:

Example:

python sign_up.py "AIDataAnalyst2025" "SecurePass123!" e35 e43 e44 e54

---
python sign_up.py "AIDataAnalyst2025" "SecurePass123!" e35 e43 e44 e54

---

2. Create Post

2. 发布帖子

Use Cases:
  • Submit a new post/submission to a forum aftering clicking "Submit" button
  • Create text posts with title and body
Usage:
bash
undefined
适用场景
  • 点击“Submit”按钮后在论坛发布新帖子/投稿
  • 创建包含标题和正文的文字帖子
使用方法
bash
undefined

Usage:

Usage:

python create_post.py <title> <body> <title_ref> <body_ref> <create_btn_ref>

python create_post.py <title> <body> <title_ref> <body_ref> <create_btn_ref>

Example:

Example:

python create_post.py "My Post Title" "Post body content here" e58 e63 e82
**Note**: The body text can contain multiple lines. Each line should start with a dash (-) for proper formatting.

---
python create_post.py "My Post Title" "Post body content here" e58 e63 e82
**注意事项**:正文内容可包含多行,每行需以短横线(-)开头以保证格式正确。

---

3. Create Forum

3. 创建论坛

Use Cases:
  • Create a new forum/community after clicking "Create forum" button
  • Set up forum name, title, description, and sidebar
Usage:
bash
undefined
适用场景
  • 点击“Create forum”按钮后创建新论坛/社区
  • 设置论坛名称、标题、描述及侧边栏内容
使用方法
bash
undefined

Usage:

Usage:

python create_forum.py <name> <title> <description> <sidebar> <name_ref> <title_ref> <desc_ref> <sidebar_ref> <create_btn_ref>

python create_forum.py <name> <title> <description> <sidebar> <name_ref> <title_ref> <desc_ref> <sidebar_ref> <create_btn_ref>

Example:

Example:

python create_forum.py "BudgetEuropeTravel" "Budget Travel Europe" "Community for sharing money-saving tips" "Share your best deals!" e51 e56 e61 e69 e83

---
python create_forum.py "BudgetEuropeTravel" "Budget Travel Europe" "Community for sharing money-saving tips" "Share your best deals!" e51 e56 e61 e69 e83

---

4. Create Wiki

4. 创建Wiki页面

Use Cases:
  • Create a wiki page for a forum after clicking "Create new page" button
  • Set up wiki URL path, title, and content
Usage:
bash
undefined
适用场景
  • 点击“Create new page”按钮后为论坛创建Wiki页面
  • 设置Wiki的URL路径、标题及内容
使用方法
bash
undefined

Usage:

Usage:

python create_wiki.py <url_path> <title> <body> <url_ref> <title_ref> <body_ref> <save_btn_ref>

python create_wiki.py <url_path> <title> <body> <url_ref> <title_ref> <body_ref> <save_btn_ref>

Example:

Example:

python create_wiki.py "europe-travel-guide" "Complete Budget Travel Guide" "Wiki content here" e51 e56 e62 e69

---
python create_wiki.py "europe-travel-guide" "Complete Budget Travel Guide" "Wiki content here" e51 e56 e62 e69

---

II. Basic Tools (When to Use Single Functions)

二、基础工具(何时使用单一函数)

Below are the basic tool functions and their use cases. These are atomic operations for flexible combination.
Note: Code should be written without line breaks.
以下是基础工具函数及其适用场景,这些是可灵活组合的原子操作。
注意事项:代码编写时请勿换行。

How to Run

运行方式

bash
undefined
bash
undefined

Standard format (browser persists across calls)

Standard format (browser persists across calls)

python run_browser_ops.py -c "await browser.navigate('http://localhost:9999')"
undefined
python run_browser_ops.py -c "await browser.navigate('http://localhost:9999')"
undefined

Navigation Tools

导航工具

navigate(url: str)

navigate(url: str)

Use Cases:
  • Open forum homepage
  • Navigate to specific forum or post
Example:
bash
python run_browser_ops.py -c "await browser.navigate('http://localhost:9999')"
python run_browser_ops.py -c "await browser.navigate('http://localhost:9999/f/MachineLearning')"

适用场景
  • 打开论坛首页
  • 导航至特定论坛或帖子
示例
bash
python run_browser_ops.py -c "await browser.navigate('http://localhost:9999')"
python run_browser_ops.py -c "await browser.navigate('http://localhost:9999/f/MachineLearning')"

navigate_back()

navigate_back()

Use Cases:
  • Go back to previous page
  • Return to forum listing after viewing post
Example:
bash
python run_browser_ops.py -c "await browser.navigate_back()"

适用场景
  • 返回上一页
  • 查看帖子后回到论坛列表页
示例
bash
python run_browser_ops.py -c "await browser.navigate_back()"

Interaction Tools

交互工具

click(ref: str, element: Optional[str] = None)

click(ref: str, element: Optional[str] = None)

Use Cases:
  • Click navigation links (Forums, Submit, Wiki, etc.)
  • Click forum links and post titles
  • Click buttons (Sign up, Create, Save, Upvote, etc.)
  • Click pagination links (More, Page 2, etc.)
Example:
bash
undefined
适用场景
  • 点击导航链接(Forums、Submit、Wiki等)
  • 点击论坛链接和帖子标题
  • 点击按钮(Sign up、Create、Save、Upvote等)
  • 点击分页链接(More、Page 2等)
示例
bash
undefined

Click Forums link

Click Forums link

python run_browser_ops.py -c "await browser.click(ref='e22', element='Forums link')"
python run_browser_ops.py -c "await browser.click(ref='e22', element='Forums link')"

Click a post title

Click a post title

python run_browser_ops.py -c "await browser.click(ref='e77', element='Post title link')"
python run_browser_ops.py -c "await browser.click(ref='e77', element='Post title link')"

Click Upvote button

Click Upvote button

python run_browser_ops.py -c "await browser.click(ref='e94', element='Upvote button')"

---
python run_browser_ops.py -c "await browser.click(ref='e94', element='Upvote button')"

---

type_text(ref: str, text: str, element: Optional[str] = None)

type_text(ref: str, text: str, element: Optional[str] = None)

Use Cases:
  • Fill form fields (username, password, title, body)
  • Enter search queries
  • Fill wiki content
Example:
bash
undefined
适用场景
  • 填写表单字段(用户名、密码、标题、正文)
  • 输入搜索查询内容
  • 填写Wiki内容
示例
bash
undefined

Enter username

Enter username

python run_browser_ops.py -c "await browser.type_text(ref='e35', text='MyUsername', element='Username field')"
python run_browser_ops.py -c "await browser.type_text(ref='e35', text='MyUsername', element='Username field')"

Enter post body

Enter post body

python run_browser_ops.py -c "await browser.type_text(ref='e63', text='Post content here', element='Body textbox')"

---
python run_browser_ops.py -c "await browser.type_text(ref='e63', text='Post content here', element='Body textbox')"

---

select_option(ref: str, element_desc: str, value: str)

select_option(ref: str, element_desc: str, value: str)

Use Cases:
  • Select timezone in user settings
  • Select sorting options
  • Select dropdown values
Example:
bash
undefined
适用场景
  • 在用户设置中选择时区
  • 选择排序选项
  • 选择下拉菜单值
示例
bash
undefined

Select timezone

Select timezone

python run_browser_ops.py -c "await browser.select_option(ref='e56', element_desc='Time zone combobox', value='Europe / Amsterdam')"

---
python run_browser_ops.py -c "await browser.select_option(ref='e56', element_desc='Time zone combobox', value='Europe / Amsterdam')"

---

press_key(key: str)

press_key(key: str)

Use Cases:
  • Submit search queries (press Enter)
  • Submit forms
Example:
bash
python run_browser_ops.py -c "await browser.press_key('Enter')"

适用场景
  • 提交搜索查询(按Enter键)
  • 提交表单
示例
bash
python run_browser_ops.py -c "await browser.press_key('Enter')"

Page State Tools

页面状态工具

snapshot()

snapshot()

Use Cases:
  • When unsure about current page state
  • Need to find ref references for elements
  • Verify if operation was successful
  • Count posts or comments on a page
Example:
bash
python run_browser_ops.py -c "await browser.snapshot()"
Best Practices:
  • Use snapshot after navigation to find element refs
  • Use snapshot to count items on a page
  • Use snapshot to verify data before submitting

适用场景
  • 不确定当前页面状态时
  • 需要查找元素的ref引用时
  • 验证操作是否成功时
  • 统计页面上的帖子或评论数量时
示例
bash
python run_browser_ops.py -c "await browser.snapshot()"
最佳实践
  • 导航后使用snapshot查找元素ref
  • 使用snapshot统计页面条目数量
  • 提交前使用snapshot验证数据

III. Common Navigation Patterns

三、常见导航模式

Forum Navigation

论坛导航

bash
undefined
bash
undefined

Navigate to homepage

Navigate to homepage

python run_browser_ops.py -c "await browser.navigate('http://localhost:9999')"
undefined
python run_browser_ops.py -c "await browser.navigate('http://localhost:9999')"
undefined

Sorting and Pagination

排序与分页

bash
undefined
bash
undefined

Click Sort by dropdown

Click Sort by dropdown

python run_browser_ops.py -c "await browser.click(ref='e54', element='Sort by: Hot dropdown')"

---
python run_browser_ops.py -c "await browser.click(ref='e54', element='Sort by: Hot dropdown')"

---

IV. Best Practices

四、最佳实践

Use snapshot() Liberally

频繁使用snapshot()

Use
snapshot()
in the following situations:
  • After navigating to a new page
  • Before performing actions that require element refs
  • When counting posts or analyzing content
  • To verify successful completion of actions
在以下场景中使用
snapshot()
  • 导航至新页面后
  • 执行需要元素ref的操作前
  • 统计帖子或分析内容时
  • 验证操作是否成功完成

Usage Principles

使用原则

  1. Navigate first: Start by navigating to
    http://localhost:9999
  2. Use snapshot() liberally: Forum pages have dynamic refs, verify state often
  3. Find refs: Always find current refs before using skills
  1. 先导航:从导航至
    http://localhost:9999
    开始
  2. 频繁使用snapshot():论坛页面的ref是动态的,需经常验证状态
  3. 查找ref:使用Skill前务必先查找当前的ref引用