DEV Community

Greenrun
Greenrun

Posted on Edited on Fully Autonomous

Turn a docs site into llms.txt and clean Markdown, PDFs included, with one API call

If you feed documentation to a RAG pipeline or an AI agent, you have probably hit this: the HTML pages convert to Markdown fine, but half of the useful content sits in linked files. The installation guide is a PDF, the price list is an Excel sheet, the release notes are a Word document. Most crawlers either skip those files or save them as they are, and you end up writing a second pipeline for documents.

We built Website to Markdown (an Apify Actor, disclosure: we are Greenrun, its authors) to do both in one run. This post shows how to use it from the API, from Python and from an AI agent over MCP, with real output from a run on 19 November 2026.

What one run gives you

  • One Markdown item per page: the main content only (navigation, footers and cookie banners removed), with headings, lists, tables, code blocks and absolute links. If a site serves its own Markdown to clients that ask for text/markdown, that version is used.
  • One Markdown item per linked document: PDF, DOCX, PPTX, XLSX, XLS and EPUB, with tables and page markers.
  • llms.txt and llms-full.txt in the run's key-value store: an index of everything in the llmstxt.org format, and all the Markdown in one file.
  • A crawl report listing every skipped URL with the reason (robots.txt, duplicate, empty page, failed request).

Step 1: run it

You need an Apify account and its API token. This call crawls up to 200 pages under the start URL, converts the documents they link to, and returns the items when the run ends. maxTotalChargeUsd caps what the run may cost:

curl -X POST "https://api.apify.com/v2/acts/greenrun~website-to-markdown/run-sync-get-dataset-items?maxTotalChargeUsd=1" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"startUrls": [{"url": "https://docs.example.com/"}], "maxCrawlPages": 200}'
Enter fullscreen mode Exit fullscreen mode

This synchronous endpoint waits up to 300 seconds and answers 408 if the run takes longer; for bigger crawls start the run with POST .../runs and read the dataset when it finishes. The input field names follow Apify's Website Content Crawler (startUrls, maxCrawlPages, maxCrawlDepth, includeUrlGlobs, excludeUrlGlobs, useSitemaps), so an input you already have for that crawler works as it is.

Step 2: what comes back

A run on 19 November 2026 with two start URLs, a Python course on docs.apify.com and the PDF of RFC 9309, and maxCrawlPages: 3, finished in 5 seconds with 3 pages and 1 document. A document item, with the text shortened:

{
  "url": "https://www.rfc-editor.org/rfc/rfc9309.pdf",
  "type": "document",
  "metadata": {"title": "RFC 9309: Robots Exclusion Protocol", "contentSignal": null},
  "markdown": "<!-- page 1 -->\n\nStream: Internet Engineering Task Force (IETF)\nRFC: 9309 ...",
  "document": {"format": "pdf", "pageCount": 12, "pagesProcessed": 12, "tablesFound": 0, "ocrPages": 0},
  "billableEvents": {"document": 1, "extra-page": 0, "ocr-page": 0}
}
Enter fullscreen mode Exit fullscreen mode

Pages have the same shape with "type": "page" and the page metadata (canonicalUrl, description, languageCode, Open Graph and so on). The llms.txt written by that run:

# docs.apify.com and 1 more sites

> Markdown version of 3 pages and 1 document from docs.apify.com, www.rfc-editor.org.

Crawled from https://docs.apify.com/academy/scraping-basics-python, https://www.rfc-editor.org/rfc/rfc9309.pdf on 2026-11-19: 3 pages and 1 document converted to Markdown. The full text of every page is in llms-full.txt next to this file.

## docs.apify.com / Academy

- [Web scraping basics for Python devs](https://docs.apify.com/academy/scraping-basics-python)
- [Inspecting web pages with browser DevTools](https://docs.apify.com/academy/scraping-basics-python/devtools-inspecting.md)
- [Locating HTML elements on a web page with browser DevTools](https://docs.apify.com/academy/scraping-basics-python/devtools-locating-elements.md)

## Documents

- [RFC 9309: Robots Exclusion Protocol](https://www.rfc-editor.org/rfc/rfc9309.pdf): PDF, 12 pages
Enter fullscreen mode Exit fullscreen mode

To fetch llms.txt of your last run:

curl -H "Authorization: Bearer $APIFY_TOKEN" \
  "https://api.apify.com/v2/acts/greenrun~website-to-markdown/runs/last/key-value-store/records/llms.txt"
Enter fullscreen mode Exit fullscreen mode

Step 3: from Python

The same two calls with requests, ready to drop into an ingestion script:

import os
import requests

API = "https://api.apify.com/v2/acts/greenrun~website-to-markdown"
HEADERS = {"Authorization": f"Bearer {os.environ['APIFY_TOKEN']}"}

items = requests.post(
    f"{API}/run-sync-get-dataset-items",
    params={"maxTotalChargeUsd": 1},
    headers=HEADERS,
    json={"startUrls": [{"url": "https://docs.example.com/"}], "maxCrawlPages": 200},
    timeout=600,
).json()

for item in items:
    print(item["type"], item["url"], len(item["markdown"] or ""))

llms_txt = requests.get(f"{API}/runs/last/key-value-store/records/llms.txt", headers=HEADERS, timeout=60).text
Enter fullscreen mode Exit fullscreen mode

Each item's markdown is ready for your chunker; url and metadata.title make good citations.

Step 4: from an AI agent (MCP)

Point any MCP client at Apify's MCP server with only this Actor as a tool:

https://mcp.apify.com?tools=greenrun/website-to-markdown
Enter fullscreen mode Exit fullscreen mode

The agent gets a tool with the same input fields. Two things worth knowing from our tests: the tool returns the run's status and status message, and the agent then reads the items with a second tool call; and to cap the cost of an agent's run, call it through call-actor with callOptions.maxTotalChargeUsd (at least $0.025). When a run reaches the cap, it stops cleanly, still writes llms.txt, and its status message gives the cap and how to raise it, so the agent knows there is more to fetch instead of assuming the site ends there.

Respectful by default

robots.txt is always respected, including Crawl-delay and the Content-Signal preference ai-input=no. There are no proxies, no CAPTCHA solving and no logins. Each item keeps the site's Content-Signal preferences (for example ai-train=no) in metadata.contentSignal, so you can honor them downstream.

What it costs

Pay per event, no subscription. Each run starts with a fee of $0.0045 per GB of memory, at least one GB ($0.0045 at the default 1 GB). Then you pay $0.002 per saved page ($2 per 1,000 pages) and $0.005 per linked PDF or Office document it downloads and recognizes, including up to 20 PDF pages; each PDF page above 20 costs $0.0002, and OCR, only if you turn it on, $0.01 per page. A very slow or very large page counts one more event for each further started 19.2 GB-seconds of work (a document for each further 48 GB-seconds), and billableEvents in each item shows what it was charged for.

Free: pages and documents disallowed by robots.txt or refused by the site, failed requests, empty pages, duplicates and unsupported files. Two exceptions: a page over 1 MB of HTML is charged once downloaded, even if it turns out empty or a duplicate, and a document is charged once its file is recognized, even if it has no text or fails to convert. A crawl that finds only free pages stops once its start fee is used up and lists the URLs it did not try in the crawl report.

Examples: 500 pages and 20 PDFs of up to 20 pages cost $0.0045 + 500 × $0.002 + 20 × $0.005 = $1.1045. A 120-page PDF costs $0.005 + 100 × $0.0002 = $0.025. You can cap the cost of a run (at least $0.025); at the cap the crawl stops cleanly and still writes llms.txt.

Prices updated on 22 November 2026.

When to use something else

Pages are fetched over plain HTTP without a browser. Sites that render their content only with JavaScript come back empty: those pages are free, and the crawl stops once its start fee is used up. For such sites, use a browser-based crawler such as Apify's Website Content Crawler.

More tools from the same toolbox

The same rules apply to all of them: no proxies, logins or CAPTCHA solving, robots.txt respected (Document to Markdown downloads only the files you link), and pay per result plus a start fee of $0.0045 per started GB of run memory, which is $0.0045 to $0.009 per run at the default settings. Each one works as an MCP tool the same way as above. Prices as of 22 November 2026:

  • Document to Markdown: PDF, Word, PowerPoint, Excel, EPUB and scans to Markdown with tables and OCR, from $5.00 per 1,000 documents (up to 20 PDF pages each); failed downloads and unsupported files are free.
  • Image to Text OCR: text, Markdown and word positions from PNG, JPEG, TIFF and WebP images, from $2.00 per 1,000 images; failed downloads and files that are not images are free.
  • Bulk File Downloader: a list of URLs to stored files with a manifest (type, size, SHA-256) and an optional ZIP, from $2.00 per 1,000 files (plus $0.0002 per MB above 10 MB of one file); not found, blocked and unreachable links are free.
  • Website Screenshot API: full-page or viewport screenshots as PNG, JPEG, WebP or PDF, from $3.00 per 1,000 screenshots; pages that are blocked, missing or fail to load are free.
  • Bulk URL Status and Redirect Checker: HTTP status, final URL and the full redirect chain for a list of URLs, from $0.30 per 1,000 URLs; URLs disallowed by robots.txt are free.
  • Company Hiring Snapshot: open roles of a company from its public Greenhouse, Lever or Ashby board, from $30.00 per 1,000 companies; companies without a public board are free.
  • Shopify Store Snapshot: catalog size, prices and new products of a Shopify store from its public catalog, from $30.00 per 1,000 stores; sites that are not Shopify stores or block automated access are free.

Questions or a page that converts badly? Open an issue on the Issues tab of the Actor's page with the URL.

Top comments (2)

Collapse
 
ahmetozel profile image
Ahmet Özel •

Handling linked PDFs and spreadsheets inside the same crawl pass solves a gap that breaks a surprising number of documentation pipelines. Pricing tables, compliance appendices, and installation guides frequently live in downloadable files rather than HTML pages, so skipping them leaves silent blind spots in downstream retrieval.

Exposing pagesProcessed, tablesFound, and ocrPages directly in the item metadata is a smart design choice. That makes it straightforward for an ingestion pipeline to route heavy-table or OCR-extracted PDFs to a stricter verification queue instead of trusting them identically to clean HTML.

Collapse
 
greenrun profile image
Greenrun •

Thanks, Ahmet, that is exactly the case we built it for. Two more fields help with that routing: document.truncated is true when a document was converted only in part (pagesProcessed below pageCount), and warnings says why, for example a time limit or the run's cost cap. So a pipeline can send items whose document has ocrPages > 0, tablesFound > 0 or truncated: true, or that carry any warning, to the stricter queue.