Skip to main content

site_to_markdown

This tool is a web scraper built using Scrapy that extracts and consolidates content from a documentation website into a single Markdown file. It is flexible, allowing you to specify a starting URL, restrict crawling to specific domains, and define the output file name.


Features

  • Crawls a documentation website starting from a given URL.
  • Automatically extracts the main content using Readability while skipping non-relevant elements (headers, sidebars, etc.).
  • Consolidates all pages into a single Markdown file with structured headings.
  • Allows optional restriction to specific domains.
  • Skips non-English pages to keep the output consistent.

Installation

This project is now available as a pip package. Install it using:

pip install site-to-markdown

Usage

The scraper can now be run directly as a command-line tool.

Command Syntax

site-to-markdown \
  -u <STARTING_URL> \
  [-d <DOMAIN1,DOMAIN2>] \
  [-o <OUTPUT_FILENAME>] \
  [-c <PATH_TO_COOKIE_JSON_FILE>]
  [-e <EXCLUDED_FILETYPE_1,EXCLUDED_FILETYPE_2>]

Arguments

  1. -u (required): The starting URL for the crawler. The scraper will begin its crawl from this URL.

    • Example: https://example-docs-site.com
  2. -d (optional): A comma-separated list of domains to restrict the crawl. If not provided, the scraper will infer the domain from the start_url.

    • Example: example-docs-site.com,docs.example.com
  3. -o (optional): The name of the output Markdown file. Default is documentation.md.

    • Example: output.md
  4. -c (optional): The path to a JSON file of cookies to use for requests. Default is None.

    • Example: ./cookies.json
  5. -e (optional): A comma-separated list of file types to exclude. This filtering is done based on the URL path, not the Content-Type.

    • Example: ./cookies.json

Example Usage

Basic Crawling

To crawl a single domain:

site-to-markdown -u [https://example-docs-site.com](https://example-docs-site.com)

Multiple Domains

To allow crawling across multiple domains:

site-to-markdown -u [https://example-docs-site.com](https://example-docs-site.com) -d example-docs-site.com,docs.example.com

Custom Output File

To specify a custom output file:

site-to-markdown -u [https://example-docs-site.com](https://example-docs-site.com) -o my_documentation.md

Exclude Filetypes

To exclude particular file types based on the HTTP Path.

site-to-markdown -u [https://example-docs-site.com](https://example-docs-site.com) -e rst.txt,md 

Output Format

The scraper generates a single Markdown file with the following structure:

# Documentation

## Page 1 Title

Content for Page 1...

## Page 2 Title

Content for Page 2...

...

Notes

  • Non-Text Content: The scraper skips non-HTML pages (e.g., images, PDFs).
  • Non-English Pages: Only English pages are processed.
  • URL Validation: Ensures only valid URLs are crawled (ignores javascript:, mailto:, etc.).
  • File Overwriting: If the output file already exists, it will be overwritten.

Contributing

Contributions are welcome! Feel free to submit pull requests or report issues on GitHub.

Metadata

Release files for site_to_markdown 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for site_to_markdown 0.2.0
File Size Uploaded Provenance
site_to_markdown-0.2.0.tar.gz 25.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for site_to_markdown 0.2.0
File Interpreter ABI Platform
site_to_markdown-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.6 kB

Release files / site_to_markdown-0.2.0.tar.gz

Download URL site_to_markdown-0.2.0.tar.gz
Size 25.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9a64e5733873ebf8e09fb64bae49025214a27303260fb3acd002c2eeaecb9f8a
BLAKE2b-256 checksum
How to use checksums
96819c192c22bf0e300310c4801635070a4968d8dc44594f66872cf50437cb6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.7

Release files / site_to_markdown-0.2.0-py3-none-any.whl

Download URL site_to_markdown-0.2.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ceb49b9d500601da8ccf3f73436372b62f3b48d0b0daaec97bef10b0159ce864
BLAKE2b-256 checksum
How to use checksums
b6380c0eaeb450732ca9827ab6f420c0a1c4094cbd15c00b39ed1237c6a562e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.7

Security for site_to_markdown 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page