jpskill.com
🛠️ 開発・MCP コミュニティ

media-auto-publisher

百家号、搜狐号、知乎といった自媒体プラットフォームへの記事投稿を自動化し、ログイン状態の確認や広告の自動クローズ、記事情報の入力・公開までをスムーズに行うSkill。

📜 元の英語説明(参考)

通用自媒体文章自动发布工具。支持百家号、搜狐号、知乎三个平台的自动化发布流程。使用Playwright MCP工具实现平台导航和发布页面进入,支持通过storageState管理Cookie实现账号切换。当用户需要发布文章到自媒体平台、打开平台发布页面、切换自媒体账号时使用此skill。工作流程:1)检查并打开指定平台 2)验证登录状态 3)自动关闭广告弹窗 4)导航到发布文章页面 5)收集发布信息 6)自动填写并发布。

🇯🇵 日本人クリエイター向け解説

一言でいうと

百家号、搜狐号、知乎といった自媒体プラットフォームへの記事投稿を自動化し、ログイン状態の確認や広告の自動クローズ、記事情報の入力・公開までをスムーズに行うSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o media-auto-publisher.zip https://jpskill.com/download/8440.zip && unzip -o media-auto-publisher.zip && rm media-auto-publisher.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/8440.zip -OutFile "$d\media-auto-publisher.zip"; Expand-Archive "$d\media-auto-publisher.zip" -DestinationPath $d -Force; ri "$d\media-auto-publisher.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して media-auto-publisher.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → media-auto-publisher フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

媒体自動パブリッシャー (Media Auto Publisher)

汎用的な自社メディア記事自動パブリッシュアシスタントで、百家号、搜狐号、知乎の3つのプラットフォームをサポートします。

快速開始

基本的な使い方

ユーザー: 百家号の公開ページを開いて
ユーザー: 知乎で記事を書くのを手伝って
ユーザー: 搜狐号に切り替えて記事を公開して
ユーザー: 百家号に記事を公開するのを手伝って

サポートされているプラットフォーム

プラットフォームコード プラットフォーム名 公開ページURL 自動化状態
baijiahao 百家号 https://baijiahao.baidu.com/builder/rc/edit?type=news ✅ 完全サポート
sohu 搜狐号 https://mp.sohu.com/api/author/article/new ✅ 完全サポート
zhihu 知乎 https://zhuanlan.zhihu.com/write ✅ Cookieログインをサポート

重大な更新: Playwright MCPを使用すると、知乎はstorageStateを使用してログイン状態を管理できるため、デバッグポートは不要になりました!

ワークフロー

標準的な公開フロー

  1. プラットフォームの確認 - ユーザーが指定したプラットフォーム(百家号/搜狐/知乎)を識別します。
  2. プラットフォームを開く - mcp__plugin_playwright_playwright__browser_navigateを使用してプラットフォームのホームページに移動します。
  3. ログインの確認 - ページスナップショットを通じて、ユーザーがログインしているかどうかを確認します。
  4. ポップアップを閉じる - 広告/キャンペーンのポップアップを自動的に検出して閉じます。
  5. 公開ページに移動 - 記事の公開ページに移動します。
  6. 情報を収集 - 記事のタイトル、内容、表紙などの情報を尋ねます。
  7. 自動入力 - 収集したすべての情報を入力します。
  8. 記事を公開 - 公開ボタンをクリックして成功を確認します。

完全な自動公開ワークフロー ⭐

ワークフローのトリガー条件

ユーザーが次のいずれかの指示を言ったときに、完全な公開フローを開始します。

  • 「[プラットフォーム]に記事を公開するのを手伝って」
  • 「[プラットフォーム]に自動的に公開する」
  • 「記事を公開したい」
  • 「[プラットフォーム]で記事を公開」

公開前の情報収集

公開を実行する前に、次の情報を順番に収集する必要があります(AskUserQuestionツールを使用)。

第一段階:基本コンテンツ(必須)

字段 説明
記事タイトル 記事のタイトル "Pythonで記事の公開を自動化する方法"
本文 Markdown形式の記事の内容 "# はじめに\nこれは本文..."

第二段階:拡張コンテンツ(オプション)

字段 説明 適用プラットフォーム
表紙画像 ローカル画像のパスまたは画像のURL 全プラットフォーム
記事の要約 記事の短い要約 百家号/搜狐号

第三段階:カテゴリとタグ(オプション)

字段 説明 適用プラットフォーム
記事のトピック/タグ 関連するトピックタグ。複数ある場合はカンマで区切ります 全プラットフォーム
質問への投稿 記事を投稿する知乎の質問 知乎
カテゴリ/コラム 記事が属するカテゴリ 百家号/搜狐号

第四段階:公開設定(オプション)

字段 説明 適用プラットフォーム
作成声明 オリジナル声明/転載声明 全プラットフォーム
公開設定 公開/自分のみに公開/公開スケジュール 全プラットフォーム
コラム 指定されたコラムに公開 知乎

各プラットフォームの詳細な公開手順

百家号の完全な公開フロー

# ステップ1:百家号のホームページに移動
mcp__plugin_playwright_playwright__browser_navigate(url="https://baijiahao.baidu.com/")

# ステップ2:ログイン状態を確認
mcp__plugin_playwright_playwright__browser_snapshot()

# ステップ3:百家号特有のポップアップを閉じる
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const closeSelectors = ['下一步', '立即体验', '我知道了', '知道了'];
    for (const selector of closeSelectors) {
        try {
            const element = await page.getByText(selector).first();
            if (await element.isVisible()) {
                await element.click();
                await page.waitForTimeout(500);
            }
        } catch (e) {}
    }
    await page.evaluate(() => {
        document.querySelectorAll('dialog, [role="dialog"], .tooltip').forEach(el => el.remove());
    });
    return { success: true };
}
''')

# ステップ4:公開ページに移動(直接移動)
mcp__plugin_playwright_playwright__browser_navigate(url="https://baijiahao.baidu.com/builder/rc/edit?type=news")

# ステップ5:記事のタイトルを入力
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const titleInput = await page.locator('input[placeholder*="请输入标题"]').first();
    await titleInput.fill('{記事タイトル}');
    return { success: true };
}
''')

# ステップ6:本文を入力(百家号はiframe内)
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const frame = page.frame({ url: /editor/ }) || page.mainFrame();
    await frame.locator('[contenteditable="true"], .editor-body').first().fill('{本文}');
    return { success: true };
}
''')

# ステップ7:表紙画像をアップロード(提供されている場合)
if 封面图片:
    mcp__plugin_playwright_playwright__browser_click(ref="三图模式")
    for 图片路径 in 封面图片列表:
        mcp__plugin_playwright_playwright__browser_file_upload(paths=["{图片路径}"])

# ステップ8:要約を入力(提供されている場合)
if 文章摘要:
    mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const summaryInput = await page.locator('textarea[placeholder*="摘要"]').first();
    await summaryInput.fill('{文章摘要}');
    return { success: true };
}
    ''')

# ステップ9:カテゴリを選択(提供されている場合)
if 文章分类:
    mcp__plugin_playwright_playwright__browser_click(ref="分类选择器")
    mcp__plugin_playwright_playwright__browser_click(ref="{分类}按钮")

# ステップ10:公開前に確認
mcp__plugin_playwright_playwright__browser_take_screenshot(path="百家号发布前预览.png")

# ステップ11:公開をクリック
mcp__plugin_playwright_playwright__browser_click(ref="发布按钮")

# ステップ12:公開が成功したことを確認
mcp__plugin_playwright_playwright__browser_wait_for(element="发布成功提示", timeout=10000)

搜狐号の完全な公開フロー


# ステップ1:搜狐号の公開ページに移動
mcp__plugin_playwright_playwright__browser_navigate(url="https://mp.sohu.com/api/author/article/new")

# ステップ2:ログイン状態を確認
mcp__plugin_playwright_playwright__browser_snapshot()

# ステップ3:ポップアップを閉じる(ある場合)
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const closeSelectors = ['我知道了', '知道了', '关闭'];
    for (const selector of closeSelectors) {
        try {
            await page.getByText(selector).first().click();
            await page.waitForTimeout(300);
        } catch (e) {}
    }
    return { success: true };
}
''')

# ステップ4:記事のタイトルを入力
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const titleInput = await page.locator('input[name="title"], input[placeholder*="标题"]').first();
    await titleInput.fill('{記事タイトル}');
    return { success: true };
}
''')

# ステップ5:本文を入力
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const editor = await page.locator('#editor, .editor-content, [contenteditable="true"]').first();
    await editor.fill('{本文}');
    return { success: true };
}
''')

# ステップ6:表紙画像をアップロード(提供されている場合)
if 封面图片:
    mcp__plugin_playwright_playwright__browser_click(ref="封面上传按钮")
    mcp__plugin_playwright_playwright__browser_file_upload(paths=["{封面图片路径}"])

# ステップ7:要約を入力(提供されている場合)
if 文章摘要:
    mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const summaryInput = await page.locator('textarea[name="summary"]').first();
    await summaryInput.fill('{文章摘要}');
    return { success: true };
}
    ''')

# ステップ8:コラムを選択(提供されている場合)
if 文章栏目:
    mcp__plugin_playwright_playwright__browser_click(ref="栏目选择器")
    mcp__plugin_playwright_playwright__browser_click(ref="{栏目}按钮")

# ステップ9:オリジナル声明を設定(必要な場合)
if 创作声明 == "原创":
    mcp__plugin_playwright_playwright__browser_click(ref="原创声明开关")

# ステップ10:公開前に確認
mcp__plugin_playwright_playwright__browser_take_screenshot(path="搜狐号发布前预览.png")

# ステップ11:公開をクリック

(原文はここで切り捨てられています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

媒体自动发布工具 (Media Auto Publisher)

通用自媒体文章自动发布助手,支持百家号、搜狐号、知乎三个平台。

快速开始

基本用法

用户: 打开百家号发布页面
用户: 帮我进入知乎写文章
用户: 切换到搜狐号发布文章
用户: 帮我发布文章到百家号

支持的平台

平台代码 平台名称 发布页面URL 自动化状态
baijiahao 百家号 https://baijiahao.baidu.com/builder/rc/edit?type=news ✅ 完全支持
sohu 搜狐号 https://mp.sohu.com/api/author/article/new ✅ 完全支持
zhihu 知乎 https://zhuanlan.zhihu.com/write ✅ 支持Cookie登录

重大更新: 使用 Playwright MCP 后,知乎可以通过 storageState 管理登录态,不再需要调试端口!

工作流程

标准发布流程

  1. 确认平台 - 识别用户指定的平台(百家号/搜狐/知乎)
  2. 打开平台 - 使用mcp__plugin_playwright_playwright__browser_navigate导航到平台首页
  3. 检查登录 - 通过页面快照验证用户是否已登录
  4. 关闭弹窗 - 自动检测并关闭广告/活动弹窗
  5. 进入发布页 - 导航到文章发布页面
  6. 收集信息 - 询问文章标题、内容、封面等信息
  7. 自动填写 - 填写所有收集到的信息
  8. 发布文章 - 点击发布按钮并验证成功

完整自动发布工作流 ⭐

工作流触发条件

当用户说以下任意指令时启动完整发布流程:

  • "帮我发布文章到[平台]"
  • "自动发布到[平台]"
  • "我要发布文章"
  • "[平台]发布文章"

发布前信息收集

在执行发布前,需要按顺序收集以下信息(使用AskUserQuestion工具):

第一阶段:基础内容(必填)

字段 说明 示例
文章标题 文章的标题 "如何用Python自动化发布文章"
正文内容 Markdown格式的文章内容 "# 引言\n这是正文..."

第二阶段:增强内容(可选)

字段 说明 适用平台
封面图片 本地图片路径或图片URL 全平台
文章摘要 文章的简短摘要 百家号/搜狐号

第三阶段:分类与标签(可选)

字段 说明 适用平台
文章话题/标签 相关话题标签,多个用逗号分隔 全平台
投稿至问题 将文章投稿到的知乎问题 知乎
分类/栏目 文章所属分类 百家号/搜狐号

第四阶段:发布设置(可选)

字段 说明 适用平台
创作声明 原创声明/转载声明 全平台
可见性设置 公开/仅自己可见/定时发布 全平台
专栏 发布到指定专栏 知乎

各平台详细发布步骤

百家号完整发布流程

python
# 步骤1:导航到百家号首页
mcp__plugin_playwright_playwright__browser_navigate(url="https://baijiahao.baidu.com/")

# 步骤2:检查登录状态
mcp__plugin_playwright_playwright__browser_snapshot()

# 步骤3:关闭百家号特有弹窗
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const closeSelectors = ['下一步', '立即体验', '我知道了', '知道了'];
    for (const selector of closeSelectors) {
        try {
            const element = await page.getByText(selector).first();
            if (await element.isVisible()) {
                await element.click();
                await page.waitForTimeout(500);
            }
        } catch (e) {}
    }
    await page.evaluate(() => {
        document.querySelectorAll('dialog, [role="dialog"], .tooltip').forEach(el => el.remove());
    });
    return { success: true };
}
''')

# 步骤4:进入发布页面(直接导航)
mcp__plugin_playwright_playwright__browser_navigate(url="https://baijiahao.baidu.com/builder/rc/edit?type=news")

# 步骤5:填写文章标题
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const titleInput = await page.locator('input[placeholder*="请输入标题"]').first();
    await titleInput.fill('{文章标题}');
    return { success: true };
}
''')

# 步骤6:填写正文内容(百家号在iframe中)
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const frame = page.frame({ url: /editor/ }) || page.mainFrame();
    await frame.locator('[contenteditable="true"], .editor-body').first().fill('{正文内容}');
    return { success: true };
}
''')

# 步骤7:上传封面图(如果提供)
if 封面图片:
    mcp__plugin_playwright_playwright__browser_click(ref="三图模式")
    for 图片路径 in 封面图片列表:
        mcp__plugin_playwright_playwright__browser_file_upload(paths=["{图片路径}"])

# 步骤8:填写摘要(如果提供)
if 文章摘要:
    mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const summaryInput = await page.locator('textarea[placeholder*="摘要"]').first();
    await summaryInput.fill('{文章摘要}');
    return { success: true };
}
    ''')

# 步骤9:选择分类(如果提供)
if 文章分类:
    mcp__plugin_playwright_playwright__browser_click(ref="分类选择器")
    mcp__plugin_playwright_playwright__browser_click(ref="{分类}按钮")

# 步骤10:发布前确认
mcp__plugin_playwright_playwright__browser_take_screenshot(path="百家号发布前预览.png")

# 步骤11:点击发布
mcp__plugin_playwright_playwright__browser_click(ref="发布按钮")

# 步骤12:验证发布成功
mcp__plugin_playwright_playwright__browser_wait_for(element="发布成功提示", timeout=10000)

搜狐号完整发布流程

python
# 步骤1:导航到搜狐号发布页
mcp__plugin_playwright_playwright__browser_navigate(url="https://mp.sohu.com/api/author/article/new")

# 步骤2:检查登录状态
mcp__plugin_playwright_playwright__browser_snapshot()

# 步骤3:关闭弹窗(如有)
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const closeSelectors = ['我知道了', '知道了', '关闭'];
    for (const selector of closeSelectors) {
        try {
            await page.getByText(selector).first().click();
            await page.waitForTimeout(300);
        } catch (e) {}
    }
    return { success: true };
}
''')

# 步骤4:填写文章标题
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const titleInput = await page.locator('input[name="title"], input[placeholder*="标题"]').first();
    await titleInput.fill('{文章标题}');
    return { success: true };
}
''')

# 步骤5:填写正文内容
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const editor = await page.locator('#editor, .editor-content, [contenteditable="true"]').first();
    await editor.fill('{正文内容}');
    return { success: true };
}
''')

# 步骤6:上传封面图(如果提供)
if 封面图片:
    mcp__plugin_playwright_playwright__browser_click(ref="封面上传按钮")
    mcp__plugin_playwright_playwright__browser_file_upload(paths=["{封面图片路径}"])

# 步骤7:填写摘要(如果提供)
if 文章摘要:
    mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const summaryInput = await page.locator('textarea[name="summary"]').first();
    await summaryInput.fill('{文章摘要}');
    return { success: true };
}
    ''')

# 步骤8:选择栏目(如果提供)
if 文章栏目:
    mcp__plugin_playwright_playwright__browser_click(ref="栏目选择器")
    mcp__plugin_playwright_playwright__browser_click(ref="{栏目}按钮")

# 步骤9:设置原创声明(如果需要)
if 创作声明 == "原创":
    mcp__plugin_playwright_playwright__browser_click(ref="原创声明开关")

# 步骤10:发布前确认
mcp__plugin_playwright_playwright__browser_take_screenshot(path="搜狐号发布前预览.png")

# 步骤11:点击发布
mcp__plugin_playwright_playwright__browser_click(ref="发布按钮")

# 步骤12:验证发布成功
mcp__plugin_playwright_playwright__browser_wait_for(element="发布成功", timeout=10000)

知乎完整发布流程

python
# 步骤1:导航到知乎写文章页面
mcp__plugin_playwright_playwright__browser_navigate(url="https://zhuanlan.zhihu.com/write")

# 步骤2:检查登录状态
mcp__plugin_playwright_playwright__browser_snapshot()

# 步骤3:关闭弹窗(如有)
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const closeSelectors = ['跳过', '以后再说', '不再提示'];
    for (const selector of closeSelectors) {
        try {
            await page.getByText(selector).first().click();
            await page.waitForTimeout(300);
        } catch (e) {}
    }
    return { success: true };
}
''')

# 步骤4:填写文章标题
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const titleInput = await page.locator('.WriteIndex-titleInput, input[placeholder*="请输入标题"]').first();
    await titleInput.fill('{文章标题}');
    return { success: true };
}
''')

# 步骤5:填写正文内容
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const editor = await page.locator('.PublicDraftEditor-content, [contenteditable="true"]').first();
    await editor.fill('{正文内容}');
    return { success: true };
}
''')

# 步骤6:上传封面图(如果提供)
if 封面图片:
    mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    await page.locator('.UploadCoverButton, [class*="upload"]').first().click();
    return { success: true };
}
    ''')
    mcp__plugin_playwright_playwright__browser_file_upload(paths=["{封面图片路径}"])

# 步骤7:添加话题标签(如果提供)
if 文章话题:
    for 话题 in 文章话题列表:
        mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    await page.locator('text=添加话题, .TopicEditor-input').first().click();
    await page.locator('input[placeholder*="搜索话题"]').fill('{话题}');
    await page.waitForTimeout(500);
    await page.locator('.TopicItem, [role="option"]').first().click();
    return { success: true };
}
        ''')

# 步骤8:投稿至问题(如果提供)
if 投稿至问题:
    mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    await page.locator('text=投稿至问题, .PublishToQuestion').first().click();
    await page.locator('input[placeholder*="搜索问题"]').fill('{问题标题}');
    await page.waitForTimeout(500);
    await page.locator('.QuestionItem, [role="option"]').first().click();
    return { success: true };
}
    ''')

# 步骤9:设置创作声明(如果需要)
if 创作声明:
    mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    await page.locator('button[class*="setting"], text=设置').first().click();
    await page.locator('text={声明类型}').first().click();
    return { success: true };
}
    ''')

# 步骤10:选择专栏(如果提供)
if 发布专栏:
    mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    await page.locator('text=选择专栏, .ColumnSelector').first().click();
    await page.locator('text={专栏名称}').first().click();
    return { success: true };
}
    ''')

# 步骤11:发布前确认
mcp__plugin_playwright_playwright__browser_take_screenshot(path="知乎发布前预览.png")

# 步骤12:点击发布
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const publishBtn = await page.getByText('发布').first();
    await publishBtn.click();
    return { success: true };
}
''')

# 步骤13:验证发布成功
mcp__plugin_playwright_playwright__browser_wait_for(element="发布成功", timeout=10000)

各平台字段选择器速查表

字段 百家号选择器 搜狐号选择器 知乎选择器
标题输入框 input[placeholder*="请输入标题"] input[name="title"] .WriteIndex-titleInput
正文编辑器 iframe .editor-body #editor .PublicDraftEditor-content
封面上传 .upload-cover-btn .cover-upload .UploadCoverButton
摘要输入框 textarea[placeholder*="摘要"] textarea[name="summary"] ❌ 不支持
分类选择器 .category-select .column-select ❌ 用话题替代
话题输入框 ❌ 不支持 .tag-input .TopicEditor-input
投稿问题 ❌ 不支持 ❌ 不支持 .PublishToQuestion
发布按钮 button:has-text("发布") button.publish-btn button:has-text("发布")

账号切换流程(推荐)

Playwright MCP 支持通过 storageState 管理多个账号:

保存登录态(首次):

// 1. 手动登录一次平台
await page.goto("https://www.zhihu.com")
// ... 用户手动登录 ...

// 2. 保存登录状态
await context.storageState({ path: 'zhihu_account1.json' })

切换账号:

// 加载已保存的登录态
const context = await browser.newContext({
  storageState: 'zhihu_account1.json'
})

关键文件

scripts/media_publisher.py 主执行脚本

快速打开平台:

python scripts/media_publisher.py baijiahao
python scripts/media_publisher.py open baijiahao

查看平台信息:

python scripts/media_publisher.py info baijiahao

生成工作流程:

python scripts/media_publisher.py workflow baijiahao
python scripts/media_publisher.py workflow sohu --output workflow.json --format json

检查登录状态:

python scripts/media_publisher.py check-login baijiahao
python scripts/media_publisher.py check-login sohu --snapshot snapshot.txt

检测弹窗:

python scripts/media_publisher.py detect-popup baijiahao
python scripts/media_publisher.py detect-popup sohu --snapshot snapshot.txt

scripts/cookie_manager.py

常用命令:

python scripts/cookie_manager.py save zhihu --account "账号1"
python scripts/cookie_manager.py list
python scripts/cookie_manager.py switch zhihu "账号1"

scripts/platform_navigator.py

平台导航助手,提供各平台的导航配置和弹窗检测逻辑。

登录状态检测

百家号:检测页面中是否存在 头像、发布作品、内容管理 等元素

搜狐号:检测页面中是否存在 发布文章、内容管理、个人中心 等元素

知乎:检测页面中是否存在 写文章、首页、通知、私信 等元素

弹窗自动关闭

百家号特有弹窗处理

python
mcp__plugin_playwright_playwright__browser_run_code(code='''
async (page) => {
    const closeSelectors = ['下一步', '立即体验', '我知道了', '知道了'];
    for (const selector of closeSelectors) {
        try {
            const element = await page.getByText(selector).first();
            if (await element.isVisible()) {
                await element.click();
                await page.waitForTimeout(500);
            }
        } catch (e) {}
    }
    await page.evaluate(() => {
        document.querySelectorAll('dialog, [role="dialog"], .tooltip').forEach(el => el.remove());
    });
    return { success: true };
}
''')

各平台常见弹窗关键词

平台 关闭按钮关键词
百家号 我知道了、下一步、立即体验、关闭、×
搜狐号 我知道了、知道了、关闭、×
知乎 跳过、以后再说、不再提示、关闭

MCP工具调用序列

Playwright MCP 工具映射

功能 Chrome DevTools MCP Playwright MCP
导航 navigate_page browser_navigate
快照 take_snapshot browser_snapshot
点击 click browser_click
填写 fill browser_fill_form / browser_type
截图 - browser_take_screenshot
等待 - browser_wait_for
执行代码 - browser_run_code
文件上传 - browser_file_upload

知乎登录解决方案

方案一:使用 storageState(推荐)

await browser.newContext({
  storageState: 'zhihu_cookies.json'
})

步骤:

  1. 先用普通 Chrome 登录知乎
  2. 使用 browser_run_code 导出 cookies
  3. 保存为 storageState 文件
  4. 后续直接加载该文件实现免登录

故障处理

问题 解决方案
未登录 提示用户先登录并保存 storageState
Cookie失效 使用cookie_manager.py重新保存登录状态
弹窗无法关闭 手动截图,分析弹窗结构后更新关闭规则
页面加载超时 使用browser_wait_for增加等待时间
知乎反爬 Playwright 的 storageState 可有效绕过检测
填写失败 使用browser_run_code直接执行JavaScript

Playwright MCP 优势

特性 Chrome DevTools Playwright
知乎登录 需要调试端口 storageState 支持
多浏览器 仅 Chrome Chrome/Firefox/Safari
Cookie管理 手动导入 storageState() API
反爬检测 自动化特征明显 可伪装真实浏览器
跨平台 依赖 Chrome 多引擎支持
文件上传 需要特殊处理 browser_file_upload

注意事项

  1. 首次登录 - 首次使用需要用户手动登录平台并保存 storageState
  2. StorageState位置 - 登录态保存在 ~/.claude/media-auto-publisher/storage_states/
  3. 平台更新 - 平台UI更新可能需要更新选择器和指示器
  4. 频率限制 - 避免频繁操作触发平台反爬机制
  5. 知乎支持 - Playwright 可以通过 storageState 实现知乎免登录发布
  6. 内容预览 - 发布前务必截图预览,确认内容无误

Playwright 高级用法

伪装真实浏览器

async (page) => {
    await page.setExtraHTTPHeaders({
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
    });
    await page.addInitScript(() => {
        Object.defineProperty(navigator, 'webdriver', {
            get: () => false
        });
    });
    await page.goto('https://zhuanlan.zhihu.com/write');
}

批量发布管理

python scripts/cookie_manager.py list
python scripts/cookie_manager.py save zhihu --account "主账号"
python scripts/cookie_manager.py save zhihu --account "小号"