confluence_web/README.md
2026-09-14 17:06:32 +03:00

49 lines
1.4 KiB
Markdown

# Confluence Crawler (PAT)
Crawls Confluence Data Center pages into Markdown files, authenticated with a
**personal access token (PAT)** from `.env`.
> ⚠️ PATs only work on **Confluence Data Center / Server 7.9+**. Confluence
> Cloud does not support PATs — use an API token (basic auth) there instead.
## Setup
```bash
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # then fill in your values
```
`.env`:
```
CONFLUENCE_URL=https://collab.lge.com
CONFLUENCE_PAT=<your personal access token>
```
Create the PAT in Confluence: avatar (top right) → Settings → **Personal access
tokens** → Create token. The token inherits your permissions — you can only
crawl pages you can see.
## Usage
```bash
python main.py --space KEY --out output/KEY # one space
python main.py --all --out output # all visible spaces
python main.py --all --max-spaces 3 --verbose # limit + debug logging
```
Each page becomes `output/<space>/<page_id>_<slug>.md` with YAML front matter
(title, page id, space, URL, version, last modified) and the body converted
from Confluence storage format to Markdown.
## Tests
```bash
pytest # unit tests + live tests (live uses the PAT from .env)
pytest -m "not live" # unit tests only, no network
pytest -m live # live tests only
```
Live tests are skipped automatically when `.env` lacks credentials.