@@ -4,7 +4,7 @@ Fetch web pages as clean markdown for AI coding agents.
44
55[ ![ CI] ( https://github.com/RandomCodeSpace/rawdoc/actions/workflows/ci.yml/badge.svg )] ( https://github.com/RandomCodeSpace/rawdoc/actions/workflows/ci.yml )
66
7- Single Go binary. No runtime downloads, no external services, no AI, no search .
7+ Single Go binary. Fetches HTML, strips noise, outputs markdown. Supports single-page fetch and multi-page crawling by depth .
88
99---
1010
@@ -14,20 +14,30 @@ Single Go binary. No runtime downloads, no external services, no AI, no search.
1414go install github.com/RandomCodeSpace/rawdoc@latest
1515```
1616
17- Single binary, no AV flags, no runtime deps.
17+ ---
18+
19+ ## What It Does
20+
21+ 1 . ** Fetches** HTML via plain HTTP with browser-like headers
22+ 2 . ** Strips** noise — scripts, styles, navbars, footers, ads, cookie banners, hidden elements
23+ 3 . ** Extracts** main content using site-specific selectors or readability scoring
24+ 4 . ** Converts** to clean markdown (headings, code blocks, tables, lists)
25+ 5 . ** Crawls** linked pages when given a depth > 0
26+
27+ Works on server-rendered sites. JS-only SPAs (React, Next.js) are not supported.
1828
1929---
2030
21- ## Quick Start
31+ ## Usage
2232
2333``` bash
24- # Single page
34+ # Single page → stdout
2535rawdoc https://kubernetes.io/docs/concepts/workloads/pods/
2636
27- # Just code blocks
37+ # Just the code blocks
2838rawdoc https://www.baeldung.com/spring-kafka --code-only
2939
30- # JSON output
40+ # JSON output with metadata
3141rawdoc https://pkg.go.dev/fmt -f json
3242
3343# YAML output
@@ -36,123 +46,105 @@ rawdoc https://pkg.go.dev/fmt -f yaml
3646# Save to file
3747rawdoc https://example.com -o docs.md
3848
39- # Crawl docs to directory
49+ # Crawl docs to a directory (depth=2, max 50 pages)
4050rawdoc https://kubernetes.io/docs/concepts/workloads/ -d 2 -o ~ /docs/k8s/
4151
42- # Verbose — see tier decisions and token stats
52+ # Verbose — see fetch decisions and token stats
4353rawdoc https://www.baeldung.com/spring-kafka -v
4454```
4555
46- ---
47-
48- ## How It Works
56+ ### Verbose Output
4957
50- Plain HTTP with full browser headers. Works for most documentation sites. JS-rendered pages (React, Next.js) are not supported — they require a real browser to execute JavaScript.
58+ ```
59+ [tier1] https://pkg.go.dev/fmt → fetching
60+ [stats] input: 139.2KB (35634 tokens) → output: 43.5KB (11135 tokens) | 69% saved
61+ [output] wrote json to docs.json
62+ ```
5163
52- Processing pipeline: ** Fetch → Strip noise → Extract content → Convert to Markdown **
64+ All verbose output goes to stderr. stdout stays clean for piping.
5365
5466---
5567
56- ## CLI Reference
57-
58- ```
59- rawdoc [flags] <url>
60- ```
68+ ## Flags
6169
6270### Output
6371
6472| Flag | Default | Description |
6573| ------| ---------| -------------|
66- | ` -o, --output PATH ` | stdout | File or directory |
67- | ` -f, --format string ` | ` markdown ` | ` markdown\| text\| json\| yaml ` |
74+ | ` -o, --output ` | stdout | File or directory |
75+ | ` -f, --format ` | ` markdown ` | ` markdown ` ` text ` ` json ` ` yaml ` |
6876| ` --code-only ` | — | Extract only code blocks |
6977| ` --no-links ` | — | Strip link URLs, keep text only |
7078
7179### Crawling
7280
7381| Flag | Default | Description |
7482| ------| ---------| -------------|
75- | ` -d, --depth int ` | ` 0 ` | Crawl depth, 0 = single page |
76- | ` -c, --concurrency int ` | ` 5 ` | Parallel fetches |
77- | ` --max-pages int ` | ` 50 ` | Page limit |
78- | ` --delay duration ` | ` 1s ` | Delay between requests |
79- | ` --include string ` | — | URL path glob to include |
80- | ` --exclude string ` | — | URL path glob to exclude |
83+ | ` -d, --depth ` | ` 0 ` | Crawl depth ( 0 = single page) |
84+ | ` -c, --concurrency ` | ` 5 ` | Parallel fetches |
85+ | ` --max-pages ` | ` 50 ` | Page limit |
86+ | ` --delay ` | ` 1s ` | Delay between requests |
87+ | ` --include ` | — | URL path glob to include |
88+ | ` --exclude ` | — | URL path glob to exclude |
8189| ` --sitemap ` | — | Parse sitemap.xml for URL discovery |
8290
8391### HTTP
8492
8593| Flag | Default | Description |
8694| ------| ---------| -------------|
87- | ` --timeout duration ` | ` 15s ` | Request timeout |
88- | ` --max-time duration ` | ` 10m ` | Total runtime ceiling |
89- | ` --max-retries int ` | ` 3 ` | Per-URL retries |
95+ | ` --timeout ` | ` 15s ` | Per-request timeout |
96+ | ` --max-time ` | ` 10m ` | Total runtime ceiling |
97+ | ` --max-retries ` | ` 3 ` | Per-URL retries with exponential backoff |
9098| ` --header K=V ` | — | Extra header (repeatable) |
9199
92100### Info
93101
94102| Flag | Description |
95103| ------| -------------|
96- | ` -v, --verbose ` | Log fetch/tier decisions and token stats to stderr |
97- | ` -q, --quiet ` | Suppress all stderr output |
104+ | ` -v, --verbose ` | Fetch log and token stats to stderr |
105+ | ` -q, --quiet ` | Suppress all stderr |
98106| ` --version ` | Print version |
99107
100108---
101109
102- ## Output Formats
103-
104- | Format | Description |
105- | --------| -------------|
106- | ` markdown ` | Clean markdown with headings, lists, code blocks (default) |
107- | ` text ` | Plain text, no markup |
108- | ` json ` | Structured JSON with metadata (url, title, content, stats) |
109- | ` yaml ` | Same as JSON but YAML-encoded |
110- | ` --code-only ` | Extracts only fenced code blocks from the page |
111-
112- ---
113-
114- ## Verbose Mode & Token Stats
115-
116- ```
117- [tier1] https://pkg.go.dev/fmt → fetching
118- [stats] input: 139.2KB (35634 tokens) → output: 43.5KB (11135 tokens) | 69% saved
119- [output] wrote json to docs.json
120- ```
121-
122- All verbose output goes to stderr, keeping stdout clean for piping.
123-
124- ---
125-
126110## Crawl Mode
127111
128- Set ` -d ` to a depth greater than 0 to crawl linked pages under the same origin path.
129-
130112``` bash
131- rawdoc https://kubernetes.io/docs/concepts/workloads/ -d 2 -o ~ /docs/k8s/
113+ rawdoc https://kubernetes.io/docs/concepts/workloads/ -d 2 --max-pages 50 - o ~ /docs/k8s/
132114```
133115
134- Output directory structure mirrors the URL path :
116+ Writes one ` .md ` file per page plus an ` index.md ` :
135117
136118```
137119~/docs/k8s/
138120├── index.md
139- ├── pods/
140- │ └── index.md
141- ├── deployments/
142- │ └── index.md
143- └── replicasets/
144- └── index.md
121+ ├── workloads.md
122+ ├── workloads-pods.md
123+ ├── workloads-controllers-deployment.md
124+ └── ...
145125```
146126
147- Use ` --sitemap ` to seed the crawl from ` sitemap.xml ` instead of link-following.
127+ Stays on the same domain. Respects ` --include ` /` --exclude ` globs and ` --max-pages ` limit.
128+
129+ ---
130+
131+ ## Output Formats
132+
133+ | Format | Description |
134+ | --------| -------------|
135+ | ` markdown ` | Headings, code blocks, tables, lists (default) |
136+ | ` text ` | Plain text, no markup |
137+ | ` json ` | Structured: url, title, content, code_blocks, fetch_tier, token count |
138+ | ` yaml ` | Same fields as JSON |
139+ | ` --code-only ` | Only fenced code blocks from the page |
148140
149141---
150142
151143## Site-Specific Selectors
152144
153- rawdoc ships with content-extraction rules for popular doc platforms and sites, so boilerplate (navbars, footers, ads) is stripped automatically:
145+ Built-in content selectors for: Baeldung, Docusaurus, GitBook, ReadTheDocs, MkDocs, Spring.io, GitHub, MDN, Go pkg.dev, StackOverflow, Medium, Dev.to, Confluence, Notion.
154146
155- Baeldung, Docusaurus, GitBook, ReadTheDocs, MkDocs, Hugo, Spring.io, GitHub, MDN, Go pkg.dev, StackOverflow, Medium, Dev.to, Confluence, Notion
147+ Falls back to readability scoring when no selector matches.
156148
157149---
158150
@@ -161,25 +153,17 @@ Baeldung, Docusaurus, GitBook, ReadTheDocs, MkDocs, Hugo, Spring.io, GitHub, MDN
161153### Claude Code (` CLAUDE.md ` )
162154
163155``` markdown
164- ## Fetching Documentation
165-
166- Use ` rawdoc ` to fetch external docs as markdown before answering questions about them:
167-
168- ``` bash
169- rawdoc < url> # pipe to stdin or save with -o
170- rawdoc < url> -f json # structured output with metadata
171- rawdoc < url> --code-only # grab only code examples
172- ```
156+ ## Tools
157+ rawdoc <url > — fetch docs as markdown
158+ rawdoc <url > --code-only — code blocks only
159+ rawdoc <url > -f json — structured output
160+ rawdoc <url > -d 2 -o dir/ — crawl to local directory
173161```
174162
175- ### Any agent via shell
163+ ### Any Agent
176164
177165``` bash
178- # Pipe directly into your agent
179- rawdoc https://pkg.go.dev/net/http | your-agent-cli
180-
181- # Save first, reference later
182- rawdoc https://docs.example.com/api -o /tmp/api-docs.md
166+ result=$( rawdoc https://docs.example.com/api)
183167```
184168
185169---
@@ -189,12 +173,12 @@ rawdoc https://docs.example.com/api -o /tmp/api-docs.md
189173| Code | Meaning |
190174| ------| ---------|
191175| ` 0 ` | Success |
192- | ` 1 ` | Fetch failure (network error, all tiers exhausted) |
176+ | ` 1 ` | Fetch failure |
193177| ` 2 ` | Usage error (bad flags, invalid URL) |
194178
195179---
196180
197- ## Building from Source
181+ ## Building
198182
199183``` bash
200184git clone https://github.com/RandomCodeSpace/rawdoc.git
@@ -205,21 +189,17 @@ go build -o rawdoc .
205189Cross-compile:
206190
207191``` bash
208- # Linux (amd64)
209- GOOS=linux GOARCH=amd64 go build -o rawdoc-linux-amd64 .
210-
211- # Windows (amd64)
212- GOOS=windows GOARCH=amd64 go build -o rawdoc-windows-amd64.exe .
213-
214- # macOS (Apple Silicon)
215- GOOS=darwin GOARCH=arm64 go build -o rawdoc-darwin-arm64 .
192+ GOOS=linux GOARCH=amd64 go build -o rawdoc-linux-amd64 .
193+ GOOS=windows GOARCH=amd64 go build -o rawdoc.exe .
194+ GOOS=darwin GOARCH=arm64 go build -o rawdoc-darwin-arm64 .
216195```
217196
218- ---
197+ ** Requires: ** Go 1.24+
219198
220- ## Requirements
199+ ---
221200
222- | Requirement | Notes |
223- | -------------| -------|
224- | Go 1.24+ | Required to build from source |
201+ ## Limitations
225202
203+ - ** JS-rendered pages** (React SPAs, Next.js CSR, Angular) return empty content — rawdoc uses plain HTTP, not a browser
204+ - ** CAPTCHA/login-gated pages** — returns whatever the public page shows
205+ - ** Single IP** — not designed for large-scale scraping or proxy rotation
0 commit comments