This project shows how to request LLM-ready Markdown from the Crawlbase Crawling API. It is intentionally small so new developers can understand each step before adapting it for larger AI, agent, or RAG pipeline workflows.
The demo uses two important Crawlbase parameters:
format=mdasks Crawlbase to return Markdown instead of raw HTML.md_readability=trueasks Crawlbase to extract the main readable page content before converting it to Markdown.
HTML is useful for browsers, but it often contains navigation, scripts, styling, tracking tags, and layout markup that are noisy for language models. Markdown is easier to chunk, embed, summarize, and pass into retrieval systems because it preserves headings, links, lists, and tables in a cleaner text format.
crawlbase_markdown_demo.py- command-line script that calls Crawlbase and saves Markdown.requirements.txt- Python dependency list..gitignore- ignores local secrets, virtual environments, caches, and generated output.
- Python 3.10 or newer
- A Crawlbase Crawling API token
- Basic terminal familiarity
Create and activate a virtual environment:
python -m venv .venv
.\.venv\Scripts\Activate.ps1Install dependencies:
pip install -r requirements.txtDo not hardcode your API token in the Python file. Set it as an environment variable instead.
PowerShell:
$env:CRAWLBASE_TOKEN = "YOUR_CRAWLBASE_TOKEN"macOS or Linux:
export CRAWLBASE_TOKEN="YOUR_CRAWLBASE_TOKEN"Fetch Markdown from the default demo URL:
python crawlbase_markdown_demo.pyFetch Markdown from a specific URL:
python crawlbase_markdown_demo.py --url "https://example.com/" --output "output/example.md"Readability extraction is enabled by default. To compare Crawlbase Markdown with and without main-content extraction, use:
python crawlbase_markdown_demo.py --url "https://example.com/" --no-md-readability --output "output/example-full-page.md"The script prints a short summary:
Markdown scrape complete
Resolved URL: https://example.com/
Original status: 200
Crawlbase status: 200
Content-Type: text/markdown; charset=utf-8
Markdown flavor: GitHub Flavored Markdown (GFM)
Readability extraction: true
Saved to: output/example.md
Open the saved .md file to inspect the Markdown body.
The script sends a GET request to:
https://api.crawlbase.com/
With these query parameters:
token=<your token>
url=<target page>
format=md
md_readability=true
The script sends md_readability=true by default. Passing --no-md-readability changes the request to md_readability=false.
Crawlbase returns the page body as Markdown. Response headers may include useful crawl metadata such as:
url- final URL Crawlbase resolved.original_status- status returned by the target website.pc_status- Crawlbase processing status.Content-Type- expected to betext/markdown; charset=utf-8.X-Markdown-Flavor- Markdown format information.
After saving Markdown, a production pipeline can:
- Split the Markdown by headings or token count.
- Store chunks in a vector database.
- Retrieve relevant chunks for a RAG prompt.
- Feed clean web context into an LLM or AI agent.
This demo focuses only on the crawling step so the API behavior is easy to see.
If you see Missing CRAWLBASE_TOKEN, set the environment variable in the same terminal session where you run the script.
If you see a non-200 pc_status, inspect the printed original_status and try another URL. Some websites may need Crawlbase's JavaScript token if their main content is rendered client-side.
If a request takes longer than expected, keep the default 90-second timeout. Crawlbase recommends allowing enough time for complex pages.