浏览器

Web to WeChat

试用

抓取任意网页内容,AI 智能整理格式,自动生成封面图和配图,发布到微信公众号草稿箱。支持微信公众号文章、新闻网站、技术博客、知乎、CSDN 等。Use when the user wants to scrape a web page and publish it to WeChat.

它能做什么

抓取任意网页内容,AI 智能整理格式,自动生成封面图和配图,发布到微信公众号草稿箱。支持微信公众号文章、新闻网站、技术博客、知乎、CSDN 等。Use when the user wants to scrape a web page and publish it to WeChat.

技能文档

Web to WeChat

抓取任意网页链接的内容,AI 智能整理排版,自动生成封面图,发布到微信公众号草稿箱。

User-Facing Promise

Accept requests like:

  • "帮我抓取这个链接的内容,发到微信公众号"
  • "把这篇文章转载到我的公众号"
  • "抓取 https://xxx.com/article 发布到微信"
  • "把这个网页内容整理成公众号文章"
  • "帮我收藏这篇文章到我的公众号"

Return a published draft in the WeChat draft box, not a proposal.

First-Time Setup

1. Install Python Dependencies

python -m pip install requests beautifulsoup4 html2text markdown Pillow

2. Install Companion Skills

This skill depends on two companion skills from ClawHub:

clawhub install anything-to-wechat
clawhub install file-to-wechat
  • anything-to-wechat — provides publish_to_wechat.py (WeChat API publishing)
  • file-to-wechat — provides md_to_wechat_html.py (Markdown → WeChat HTML)

3. Configure WeChat Credentials

You need a WeChat Official Account (服务号 or 订阅号 with API access).

Get your credentials:

  1. Log in to https://mp.weixin.qq.com/
  2. Go to: 设置与开发 → 基本配置
  3. Copy your AppID and reset/view AppSecret
  4. Add your server's public IP to the IP白名单

Set environment variables (recommended):

On macOS / Linux:

export WECHAT_APP_ID="your_appid_here"
export WECHAT_APP_SECRET="your_appsecret_here"

On Windows (PowerShell):

[Environment]::SetEnvironmentVariable("WECHAT_APP_ID", "your_appid_here", "User")
[Environment]::SetEnvironmentVariable("WECHAT_APP_SECRET", "your_appsecret_here", "User")

No environment variables? The publish script will prompt you interactively on first run.

Prerequisites

DependencyRequiredPurpose
requests (pip)YesHTTP fetching
beautifulsoup4 (pip)YesHTML parsing
html2text (pip)YesHTML → Markdown conversion
markdown (pip)YesMarkdown → HTML (via md_to_wechat_html.py)
Pillow (pip)YesImage compression
anything-to-wechat skillYesWeChat API publishing
file-to-wechat skillYesMarkdown → WeChat HTML conversion

Workflow

Phase 1: Collect Input

If the user has NOT provided a URL, ask using AskUserQuestion:

Question: "请提供你想抓取并发布到微信公众号的网页链接"
Options:
  - "粘贴 URL"
  - "搜索关键词后选择文章"

If the user already provided a URL, skip and proceed.

Phase 2: Scrape Web Content

IMPORTANT: Always use UTF-8 encoding on Windows.

Primary: Use scrape_web.py script (structured extraction)

python "/scripts/scrape_web.py" \
  --url "" \
  --output "/raw_article.md" \
  --json

The --json flag outputs structured data including title, author, date, cover URL, and Markdown content.

Fallback: Use WebFetch tool (for JS-rendered pages)

If scrape_web.py fails (e.g., the page requires JavaScript rendering), use the built-in WebFetch tool:

WebFetch(url="", prompt="Extract the full article content including: title, author, publish date, and the complete article text. Return in a structured format.")

Then manually compose the Markdown from the WebFetch output.

After scraping: Read the output. Inspect the content structure and quality. Proceed to Phase 3.

Phase 3: AI Content Reformatting

This is the key quality step. The agent should:

  1. Read the scraped Markdown content
  2. Rewrite/reformat the content for WeChat publishing:
    • Ensure clean heading hierarchy (H1 → H2 → H3)
    • Fix broken formatting (tables, lists, code blocks)
    • Remove navigation artifacts, ads, social media buttons
    • Ensure paragraphs flow naturally
    • Add section breaks where appropriate
    • Keep the original meaning and facts intact
  3. Output a clean, well-structured Markdown file

Style options (ask user or auto-detect):

StyleWhen to use
忠实转载 (faithful reprint)User wants exact copy, just clean formatting
精华摘要 (key highlights)Long article → condensed version with key points
深度改写 (deep rewrite)Rewrite in user's own voice/style

Save the reformatted Markdown:

Write the reformatted content to /article.md using the Write tool.

Phase 4: Generate Cover Image

Use the ImageGen tool with a prompt derived from the article's topic and content.

  • Save as wechat_cover.png in the workspace.
  • Size: 1024x768 (WeChat cover ratio 4:3).
  • Make it visually compelling and relevant to the article topic.

Phase 5: Compress Cover Image

WeChat requires cover images (thumb_media_id) to be under 64KB.

python "/scripts/compress_image.py" \
  --input "/wechat_cover.png" \
  --output "/wechat_cover_compressed.jpg" \
  --max-size 64

If the original cover is already under 64KB (rare for PNG), this step can be skipped. But always run it to be safe — it won't enlarge files.

Fallback: If compress_image.py fails to reach 64KB, use ImageGen to regenerate a simpler cover image (fewer details, simpler composition) and try again.

Phase 6: Convert to WeChat HTML

Use md_to_wechat_html.py from the file-to-wechat skill:

python "/scripts/md_to_wechat_html.py" \
  --input "/article.md" \
  --output "/wechat_article.html" \
  --title ""

This generates WeChat-compatible inline-style HTML with Clockless design tokens.

Phase 7: Publish to WeChat Draft Box

On Windows, use Python subprocess to pass environment variables:

python -c "
import os, subprocess, sys
os.environ['WECHAT_APP_ID'] = ''
os.environ['WECHAT_APP_SECRET'] = ''
result = subprocess.run([
    sys.executable,
    r'/scripts/publish_to_wechat.py',
    '--file', r'/wechat_article.html',
    '--title', '',
    '--cover', r'/wechat_cover_compressed.jpg',
    '--digest', '',
    '--source-url', ''
], capture_output=True, text=True, encoding='utf-8')
print(result.stdout)
print(result.stderr)
"

Or with environment variables already set:

python "/scripts/publish_to_wechat.py" \
  --file "/wechat_article.html" \
  --title "" \
  --cover "/wechat_cover_compressed.jpg" \
  --digest "" \
  --source-url ""

Credentials: The script reads from WECHAT_APP_ID / WECHAT_APP_SECRET env vars. If not set, it prompts interactively.

Phase 8: Confirm & Handoff

Report success with Media ID and link to https://mp.weixin.qq.com/.

Tell the user: "文章已发送到你的微信公众号草稿箱,请登录微信公众平台审核后一键发布。"

Include:

  • Original source URL
  • Article title
  • Content summary
  • Media ID

Site Compatibility

SiteScraping MethodNotes
WeChat articles (mp.weixin.qq.com)scrape_web.pyAnti-scraping: may need WebFetch fallback
Toutiao / 今日头条scrape_web.pyJS-heavy, may need WebFetch
Zhihu / 知乎scrape_web.pyLogin wall for some content
CSDNscrape_web.pyWorks well
Juejin / 掘金scrape_web.pyWorks well
Mediumscrape_web.pyWorks well
News sites (generic)scrape_web.pyAuto-detects article content
JS-rendered SPAsWebFetchUse browser rendering fallback

Error Handling

ErrorAction
Page returns 403/404Try WebFetch; if blocked, inform user
Content too short (<200 chars)Page may be JS-rendered, try WebFetch
Chinese characters garbledscrape_web.py auto-detects encoding
Cover image > 64KBRun compress_image.py; regenerate if needed
Images not loading in WeChatpublish_to_wechat.py auto-uploads to WeChat CDN
WeChat credentials missingScript prompts interactively
IP not in whitelistShow IP from error, guide user to mp.weixin.qq.com
WebFetch returns emptyPage has strong anti-scraping, inform user
Content copyrightedAdd disclaimer, keep source attribution

IMPORTANT: When republishing web content:

  1. Always include the original source URL in the article metadata
  2. Preserve the original author's name when available
  3. Add a disclaimer line at the end: "本文内容来源于[原作者名称],原文发布于[来源网站]。如有侵权请联系删除。"
  4. Use --source-url when publishing to add a "Read More" link
  5. Consider using "精华摘要" or "深度改写" style instead of exact copy to avoid copyright issues

Script Reference

ScriptPurpose
scripts/scrape_web.pyWeb scraping → clean Markdown (supports 10+ site types)
scripts/compress_image.pyImage compression (target 64KB for WeChat cover)
file-to-wechat/scripts/md_to_wechat_html.pyMarkdown → WeChat inline HTML
anything-to-wechat/scripts/publish_to_wechat.pyWeChat draft box publishing

Configuration

VariableRequiredDescription
WECHAT_APP_IDYesWeChat Official Account AppID (or prompted interactively)
WECHAT_APP_SECRETYesWeChat Official Account AppSecret (or prompted interactively)

相关技能

通过 API、Chrome 或远程 SSH 隧道把文章和图文发布到微信公众号。

143 次安装

使用 Playwright headed 模式 + 真实系统浏览器抓取微信公众号文章。 当用户给出 mp.weixin.qq.com 链接、说要抓取/下载公众号文章、 或遇到"环境异常"验证页时,必须使用本技能。 本技能会弹出真实浏览器窗口绕过微信反爬,提取文章标题、作者、正文, 并同时保存 .md 和 .htm...

Take existing HTML content (file, URL, or pasted HTML) and publish it directly to WeChat Official Account draft box. No file conversion, no web scraping — ju...

1 次安装

抓取微信公众号文章、搜索公众号、文章列表、爆款查询与分析。触发场景:mp.weixin.qq.com 链接、微信公众号文章、公众号文章分析。

15 次安装

One-step workflow: accept any file (PDF, DOCX, CSV, Markdown), folder, URL, or idea → generate polished HTML via html-anything → auto-convert for WeChat comp...