# Recursive Downloading & Website Mirroring goget can recursively download linked pages and mirror entire websites for offline viewing. This document explains the two modes, their configuration, and the underlying architecture. ## Quick Comparison | Feature | Recursive (`--recursive`) | Mirror (`--mirror`) | |---|---|---| | Depth limit | By default (`--max-depth N`) | Infinite | | Link conversion | Optional (`--convert-links`) | Automatic | | Page requisites | Manual (`--page-requisites`) | Automatic | | robots.txt | Respected by default | Respected by default | | Use case | Download a subtree of a site | Full offline archive | ## Recursive Mode Recursive mode follows links from HTML pages and downloads linked resources. ```bash # Basic recursive download, depth 3 goget --url https://example.com/docs/ --recursive --max-depth 3 # Only PDF files goget --recursive --accept "*.pdf" --url https://example.com/docs/ # Only images and HTML goget --recursive --accept "image/*,text/html" --url https://example.com/ ``` ### Link Filtering ```mermaid flowchart TD HTML[Parse HTML page]:::accent1 Extract["Extract all links\n(a, img, link, script)"]:::accent1 FilterByDomain{"Domain match?"}:::accent7 FilterByPattern{"Accept pattern\nmatch?"}:::accent7 FilterByDepth{"Depth ≤ max?"}:::accent7 FilterByParent{"No-parent\ncheck?"}:::accent7 ExcludeFilter{"Not in exclude\nlist?"}:::accent7 Enqueue["Add to download queue"]:::accent1 Skip["Skip"]:::accent4 HTML --> Extract --> FilterByDomain FilterByDomain -->|Yes| FilterByPattern FilterByDomain -->|No, --span-hosts| FilterByPattern FilterByDomain -->|No| Skip FilterByPattern -->|Yes| FilterByDepth FilterByPattern -->|No| Skip FilterByDepth -->|Yes| FilterByParent FilterByDepth -->|No| Skip FilterByParent -->|Pass| ExcludeFilter FilterByParent -->|Fail| Skip ExcludeFilter -->|Pass| Enqueue ExcludeFilter -->|Fail| Skip classDef accent1 fill:#22C55E,stroke:#16A34A,color:#fff classDef accent4 fill:#EF4444,stroke:#DC2626,color:#fff classDef accent7 fill:#64748B,stroke:#475569,color:#fff ``` ### Accept Patterns The `--accept` flag supports two types: | Type | Example | Matches | |---|---|---| | **Glob** | `*.pdf` | Filenames ending in `.pdf` | | **Glob** | `*.html,*.css` | Multiple patterns (comma-separated) | | **MIME** | `text/html` | Exact MIME type | | **MIME** | `image/*` | Any MIME in the `image/` category | ### Domain Control | Flag | Effect | |---|---| | (default) | Only follow links within the starting domain | | `--span-hosts` | Follow links to any domain | | `--domains a.com,b.com` | Restrict to specific domains | | `--follow-external` | Follow external links (aliases for `--span-hosts`) | | `--no-parent` | Don't ascendant above the starting URL path | | `--recursive-parallel` | `` | Number of concurrent file downloads in recursive mode across all protocols (`0` = sequential). HTTP, WebDAV, FTP, and SFTP each get a worker pool bounded by a semaphore; subdirectory recursion propagates the limit. Connection pooling (FTP, SFTP) opens N independent control connections | ### Request Throttling ```bash # Fixed 2-second delay between requests goget --recursive --wait 2s --url https://example.com/docs/ # Randomize delay (0.5x – 1.5x of --wait) goget --recursive --wait 2s --random-wait --url https://example.com/docs/ ``` ### Page Requisites `--page-requisites` downloads CSS, JavaScript, and images needed to render each HTML page: ```bash goget --recursive --page-requisites --url https://example.com/page.html ``` This parses ``, `