The substack_scraper.py script can be run with various arguments to control the scraping process. You can either hardcode the URL and post count in the script or pass them via the command line.
Common Commands
Scrape a free Substack:
python substack_scraper.py --url https://example.substack.com --directory /path/to/save/posts
Scrape a premium Substack:
Requires config.py to be set up and Microsoft Edge installed.
python substack_scraper.py --url https://example.substack.com --directory /path/to/save/posts --premium
Scrape a single post:
python substack_scraper.py --url https://example.substack.com/p/my-post
Download images locally:
Downloads Substack-hosted images and rewrites the Markdown links to point to local files.
python substack_scraper.py --url https://example.substack.com --images
Limit the number of posts:
python substack_scraper.py --url https://example.substack.com --directory /path/to/save/posts --number 5
Emit MDX-compatible frontmatter:
Instead of standard headers, this uses YAML frontmatter (title, subtitle, date, author, image) suitable for MDX sites.
python substack_scraper.py --url https://example.substack.com --frontmatter mdx