How a crawl works
The steps of one run, from the start URL to the summary, and what each step does with the site.
A crawl runs in rounds. The first round holds the start URL and, with the sitemap switched on, the pages listed in the site’s sitemaps. Every page that is fetched can add its same-site links to the next round, until no unseen URL is left or the maximum depth is reached.
Focus
Source: src/cli.rs, src/crawler.rs, src/parsers/sitemap.rs, src/parsers/links.rs, src/processors/html.rs, src/processors/stylesheet.rs, src/processors/image.rs
Show chart data
| Step | Kind | Lane | Leads to |
|---|---|---|---|
| site-scraper <URL> | start | site-scraper | Follow redirects |
| Follow redirects | external | The website | Clear output/<domain>/ |
| Clear output/<domain>/ | data store | site-scraper | Sitemap on, depth ≥ 1? |
| Sitemap on, depth ≥ 1? | decision | site-scraper | robots.txt, sitemap.xml (yes), Next round (no) |
| robots.txt, sitemap.xml | external | The website | Next round |
| Next round | step | site-scraper | GET page |
| GET page | external | The website | text/html? |
| text/html? | decision | site-scraper | CSS, JS, images (yes) |
| CSS, JS, images | external | The website | Rewrite references |
| Rewrite references | step | site-scraper | <path>/index.html |
| <path>/index.html | data store | site-scraper | Below max depth? |
| Below max depth? | decision | site-scraper | Next round (yes: same-origin links), Summary (queue empty) |
| Summary | end | site-scraper |
Focus
Source: src/cli.rs, src/crawler.rs, src/parsers/sitemap.rs, src/parsers/links.rs, src/processors/html.rs, src/processors/stylesheet.rs, src/processors/image.rs
Show chart data
| Step | Kind | Lane | Leads to |
|---|---|---|---|
| site-scraper <URL> | start | site-scraper | Follow redirects |
| Follow redirects | external | The website | Clear output/<domain>/ |
| Clear output/<domain>/ | data store | site-scraper | Sitemap on, depth ≥ 1? |
| Sitemap on, depth ≥ 1? | decision | site-scraper | robots.txt, sitemap.xml (yes), Next round (no) |
| robots.txt, sitemap.xml | external | The website | Next round |
| Next round | step | site-scraper | GET page |
| GET page | external | The website | text/html? |
| text/html? | decision | site-scraper | CSS, JS, images (yes) |
| CSS, JS, images | external | The website | Rewrite references |
| Rewrite references | step | site-scraper | <path>/index.html |
| <path>/index.html | data store | site-scraper | Below max depth? |
| Below max depth? | decision | site-scraper | Next round (yes: same-origin links), Summary (queue empty) |
| Summary | end | site-scraper |
Before the first request
- Redirects: the start URL is requested once and its redirects are followed, so a crawl of
https://www.example.comthat ends up onhttps://example.comuses the bare domain for the output directory and for the same-site check. - Output directory:
output/<domain>/is removed and created again. Each run leaves exactly one snapshot per domain. - Sitemap seeds: with
--sitemap(the default) and a depth of at least 1, site-scraper reads theSitemap:lines inrobots.txtand the well-known paths/sitemap.xml,/sitemap_index.xmland/wp-sitemap.xml. Sitemap indexes and gzipped sitemaps are unpacked; only URLs on the same origin are kept, and they count as depth 1.
One page
- Fetch: a
GETwith browser-like headers (or--botheaders), after the configured delay plus a little jitter, with up to three tries. In headless mode a Chrome tab loads and renders the page instead; everything after this step is the same. - HTML only: responses that are not
text/html, such as a linkedsitemap.xml, are counted but not saved and add no links. - Assets: stylesheets, scripts and images are downloaded in parallel. CSS files are
rewritten as well, so fonts and background images referenced with
url()come along. External CSS and JavaScript follow--allow-external-assets, images follow--placeholder(Images and assets). - Rewrite: every reference, including links to other pages of the site, becomes a relative local path, so the copy opens straight from disk.
- Save: the page is written to the path of its URL, with
index.htmlfor directories, for examplehttps://example.com/blog/toblog/index.html. - Links: if the page is below
--max-depth, its<a href>links on the same origin go into the next round.mailto:,tel:andjavascript:links and fragments are dropped, and a URL is only fetched once.
The summary
When the queue is empty, site-scraper prints the output directory and a summary with pages,
failures, warnings and duration. A page that returns 404 but is listed in the sitemap only counts
as a warning, because stale sitemap entries are common. Any other failed page makes the exit code
1 (Output and exit codes).