wechat-article-markdown (Go Library)
中文文档
A reusable Go library that converts WeChat Official Account article URLs into structured markdown output, with pluggable storage and driver interfaces.
Table of Contents
Features
- Unified entrypoint:
Convert(ctx, url, opts) via Converter
- Pluggable
Driver interface (official API, anti-bot browser, HTML fetcher, etc.)
- Default
HTMLDriver for direct HTTP fetching
- Pluggable
Parser with default WechatParser (metadata extraction + markdown conversion)
- Pluggable
Storage interface with default LocalStorage
Install
go get github.com/SolaTyolo/wechat-article-markdown
Quick Start
converter := wechatmd.NewConverter()
res, err := converter.Convert(ctx, "https://mp.weixin.qq.com/s/xxxx", core.ConvertOptions{
OutputRoot: "output",
})
Default output structure:
output/
└── <article-title>/
├── <article-title>.md
└── images/
├── img_001.png
├── img_002.png
└── ...
Extensibility
Custom Driver
Implement and inject a Driver:
type MyDriver struct{}
func (d *MyDriver) Fetch(ctx context.Context, url string) (*core.FetchResult, error) {
// Official API / anti-bot browser / any custom fetch logic
}
Custom Storage (e.g. S3)
Implement and inject a Storage:
type S3Storage struct{}
func (s *S3Storage) Save(ctx context.Context, article *core.ArticleResult) error {
// Upload article.Markdown and article.Images
}
Example
go run ./examples/basic "https://mp.weixin.qq.com/s/xxxx"
CLI
Build/install locally:
go install ./cmd/wechat-article-markdown
Run:
wechat-article-markdown -o output "https://mp.weixin.qq.com/s/xxxx"