# Get all pages from GitBook

#### You:
how do i get all pages text for claude from gitbook

#### ChatGPT:
If the docs are hosted on GitBook, the easiest way is usually **not scraping pages one by one**.

### Option 1: Use GitBook's built-in LLM export (best)

GitBook exposes:

- `/llms.txt` → index of all documentation pages
- `/llms-full.txt` → full documentation content in one text file
- Any page with `.md` appended → markdown version of that page

Example:

```text
https://docs.example.com/llms.txt
https://docs.example.com/llms-full.txt
```

GitBook specifically documents `llms.txt` and `llms-full.txt` as LLM-friendly exports. ([GitBook](https://gitbook.com/docs/publishing-documentation/llm-ready-docs?utm_source=chatgpt.com))

So for Claude:

1. Open `https://your-docs-site.com/llms-full.txt`
2. Copy the contents
3. Upload it to Claude or paste it into a Project knowledge file

If the file is very large, use `llms.txt` and fetch only the pages you need. ([GitBook](https://gitbook.com/docs/publishing-documentation/llm-ready-docs?utm_source=chatgpt.com))

---

### Option 2: Get all pages as Markdown

GitBook automatically serves markdown versions of pages.

Example:

```text
https://docs.example.com/getting-started
```

becomes

```text
https://docs.example.com/getting-started.md
```

GitBook states that every docs page is available as a markdown file by appending `.md`. ([GitBook](https://gitbook.com/docs/publishing-documentation/llm-ready-docs?utm_source=chatgpt.com))

You can:

1. Read `llms.txt`
2. Extract all URLs
3. Append `.md`
4. Download each page
5. Concatenate them into a single file for Claude

---

### Option 3: Use the GitBook API (private spaces)

If you own the GitBook space or have API access:

1. Get the space structure:
   ```http
   GET /v1/spaces/{spaceId}/content
   ```

2. Fetch each page:
   ```http
   GET /v1/spaces/{spaceId}/content/page/{pageId}?format=markdown
   ```

GitBook's API supports retrieving pages directly in markdown format. ([GitBook](https://gitbook.com/docs/developers/gitbook-api/api-reference/spaces/space-content?utm_source=chatgpt.com), [GitBook](https://gitbook.com/docs/developers/gitbook-api/api-reference?utm_source=chatgpt.com))

Example:

```bash
curl \
  -H "Authorization: Bearer YOUR_TOKEN" \
  "https://api.gitbook.com/v1/spaces/SPACE_ID/content/page/PAGE_ID?format=markdown"
```

---

### Quick script for public GitBook docs

If the site has `llms.txt`:

```python
import requests

base = "https://docs.example.com"

index = requests.get(f"{base}/llms.txt").text

urls = [
    line.strip()
    for line in index.splitlines()
    if line.startswith("http")
]

all_text = []

for url in urls:
    md_url = url.rstrip("/") + ".md"
    try:
        all_text.append(requests.get(md_url).text)
    except Exception:
        pass

with open("gitbook_docs.md", "w", encoding="utf-8") as f:
    f.write("\n\n---\n\n".join(all_text))
```

This gives you a single markdown file you can upload to Claude.

If you share the GitBook URL, I can tell you which of these methods works for that specific site.
