English | 中文文档
Blog2MD is an intelligent tool designed to convert web articles (from platforms like WeChat, Toutiao, Juejin, and more) into clean, local Markdown files.
Unlike traditional converters that rely solely on regex or simple HTML parsing, Blog2MD leverages Large Language Models (LLMs) (such as OpenAI GPT-4, DeepSeek, Qwen) to:
- Intelligently format the content into high-quality Markdown.
- Automatically categorize articles based on their content.
- Preserve and download images locally for offline access.
It comes with a modern Web Interface for easy management, monitoring, and reading.
(Replace with actual screenshot if available)
- 🤖 LLM-Powered Conversion: Uses AI to strip clutter and format text perfectly.
- 📂 Auto-Categorization: Automatically organizes articles into folders like "Technology", "Finance", "News", etc.
- 🖼️ Image Archiving: Downloads all images to a local
assetsfolder and updates links, ensuring your markdown is truly offline-ready. - 🌍 Multi-Platform Support:
- WeChat Official Accounts (微信公众号)
- Toutiao (今日头条) - Supports mobile/short links & redirects
- Juejin (掘金)
- Generic (Fallbacks for other websites)
- 🖥️ Modern Web UI:
- Built with FastAPI & Tailwind CSS.
- Dark Mode support.
- Real-time Monitoring of conversion tasks via WebSockets.
- PDF Export: Convert your archived Markdown articles to PDF with proper font support.
- Management: View, read, and delete categories or articles directly from the browser.
- Python 3.8 or higher.
- An API Key for an LLM provider (OpenAI, DeepSeek, DashScope/Qwen, etc.).
-
Clone the repository:
git clone https://github.com/your-username/blog2md.git cd blog2md -
Install dependencies:
pip install -r requirements.txt
-
Configure Environment: Copy the example environment file and edit it:
cp .env.example .env
Open
.envand set your LLM provider and API keys. Example:# Options: openai, deepseek, qwen, kimi, doubao, custom LLM_PROVIDER=openai # OpenAI Configuration OPENAI_API_KEY=sk-your-key-here OPENAI_MODEL=gpt-4o-mini # Or for DeepSeek # LLM_PROVIDER=deepseek # DEEPSEEK_API_KEY=sk-your-deepseek-key # DEEPSEEK_MODEL=deepseek-chat
-
Build and Run with Docker Compose (Recommended):
docker-compose up -d
-
Access the application: http://localhost:8000
-
Custom Configuration:
- Port: Change the port by setting the
PORTenvironment variable.Then access at http://localhost:9000PORT=9000 docker-compose up -d
- Output Mapping: The
outputdirectory is automatically mapped to./outputin your project root. - Fonts: If you need custom fonts, you can uncomment the fonts volume mapping in
docker-compose.yml.
- Port: Change the port by setting the
Start the web server:
python server.pyOpen your browser and navigate to: http://localhost:8000
- Click "Fetch URL" to add a new article.
- View your knowledge base in the home page.
- Monitor background tasks in the "Monitor" tab.
Easily send articles from your phone to Blog2MD while on the same Wi-Fi.
Note: Replace
192.168.1.82in the examples below with your computer's actual LAN IP address.
- Open the Shortcuts app on your iPhone.
- Tap "+" to create a new shortcut.
- Add action "Get Contents of URL".
- URL:
http://192.168.1.82:8000/api/quick_add?url= - After the
=, select "Shortcut Input" from the variable bar.
- URL:
- Tap the "i" icon (or shortcut name) and enable "Show in Share Sheet".
- Tap "Receive" settings at the top:
- Set to receive "Safari web pages" or "URLs".
- Name it "Save to Blog2MD".
Usage: In Safari/Apps, tap Share -> "Save to Blog2MD".
- Install HTTP Shortcuts app.
- Create a new shortcut.
- Basic Settings:
- Name: Save to Blog2MD
- URL:
http://192.168.1.82:8000/api/quick_add?url={share_text}
- Request Method: GET
- Enable "Show in Share Sheet".
Create a bookmark in your mobile browser with the following URL (Address):
javascript:(function(){window.location.href='http://192.168.1.82:8000/api/quick_add?url='+encodeURIComponent(window.location.href);})();Usage: While viewing an article, tap the address bar and select this bookmark.
You can also use the tool directly from the terminal:
python main.py https://mp.weixin.qq.com/s/some-article-urlOr simply run python main.py and paste the URL when prompted.
All converted articles are saved in the output directory:
output/
├── Technology/
│ ├── Understanding_LLMs/
│ │ ├── index.md
│ │ └── assets/
│ │ ├── image1.jpg
│ │ └── image2.png
├── Finance/
│ ├── Market_Trends_2025/
│ │ ├── index.md
│ │ └── assets/
│ ...
- Backend: Python, FastAPI, Uvicorn
- Frontend: HTML5, Jinja2 Templates, Tailwind CSS, JavaScript
- AI/LLM: LangChain (integrating OpenAI, DeepSeek, DashScope, etc.)
- Scraping: Requests, BeautifulSoup4
- Utilities: Markdown, xhtml2pdf