Skip to content
Projets

À propos

Python script to capture full websites and all assets for local offline use

Données et analyse

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
Historique en cours
in 7 days
Historique en cours
in 15 days
Historique en cours
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

Website Downloader — Python Site Asset Automation for Windows 10 & 11

💻 PowerShell Installer

build lang powershell-7


Website Downloader is a Python script that pulls an entire site—pages, stylesheets, scripts, images, fonts, and media—into a local mirror you can browse offline. It rewrites links as it goes so the copy works from disk without chasing broken references. The script stays deliberately lean: no heavyweight crawler framework, just readable Python you can extend when your needs outgrow the defaults. Point it at a URL you're authorized to copy, set your limits, and let it handle the rest.

📋 System Requirements

  • PowerShell 5.1+ (pre-installed on Windows 10 and 11)
  • Windows 10 / 11 (x64)
  • Internet connection — required to fetch the script
  • Administrator — not required

What it does

Website Downloader walks a site from one or more starting URLs and writes a browsable copy to disk. Give it a URL and a destination, and it fetches the HTML, follows same-site links up to your page limit, and pulls down the assets each page needs — stylesheets, scripts, images, fonts, media, and metadata images. References are rewritten as it goes, so the saved pages open and navigate locally without a network connection.

Crawling is configurable rather than all-or-nothing. You can seed from a sitemap, follow links only a set number of hops from each start, skip sections with glob patterns, and cap total pages or per-asset size. Assets hosted on separate CDNs can be pulled in through a domain allowlist. For sites behind a login or staging header, the script reuses cookies and custom headers you supply, so authorized portals mirror the same way public pages do.

Two details matter for real sites. First, client-rendered pages that expose nothing until JavaScript runs can be handled with optional browser rendering, which you enable only when a plain fetch returns an empty shell. Second, repeated runs can skip resources the server reports as unchanged, so --update refreshes a mirror without re-downloading everything. Request pacing is polite by default: pages are fetched one at a time unless you opt into parallel workers, and you can add delays, honor robots rules, and retry with backoff.

The output stays portable. Mirrors can be exported as a zip or a WARC response archive, and an optional JSON manifest records what was downloaded, cached, skipped, or failed, along with page titles and headings — useful when the crawl feeds an automated pipeline. Paths are sanitized for Windows reserved names and long path limits, and query strings are hashed to avoid collisions, so the same mirror works across platforms. The result is a small, readable Python codebase you can extend without adopting a full crawler framework.

Configuration

Everything ships with sane defaults, so you can point the script at a URL and go. The settings below exist for when the defaults don't fit your target. Pass them as CLI flags; each flag maps to a single option, and options you leave alone stay out of the way.

Core crawl settings

  • --url — the starting page. Repeat it to seed several entry points in one run, or use --url-file to read a plain list (one URL per line, blank lines ignored).
  • --destination — where the mirror lands on disk. Created if missing; existing files are only overwritten when the crawler actually re-fetches them.
  • --max-pages — hard ceiling on pages fetched. Default is unlimited, which is rarely what you want on a real site.
  • --max-depth — how many link-hops to follow from each starting URL. 0 mirrors only the seeds themselves.
  • --page-threads — concurrent page fetches. Stays at 1 by default to keep traffic gentle; raise it only when the host can take it.
  • --delay — seconds between requests. Pair with --respect-robots when crawling anything you don't control.
  • --user-agent — set an identifiable string so server logs show who's knocking.

Assets and references

  • --download-external-assets — pull CDN-hosted assets into cdn/<domain>/… instead of leaving them pointing at the live web.
  • --external-domains — narrow that behavior with an allowlist, so only the hosts you name get mirrored. Without it, external asset fetching applies to whatever the page references.
  • --max-asset-bytes — per-asset size cap. Oversized files are skipped and logged rather than blowing up the mirror.
  • --exclude / --exclude-file — glob patterns matched against the full URL and the path. Load a longer list from a file instead of stacking flags.

Access and sessions

  • --cookie-file — a plain cookie header string (name=value; name2=value2) for portals and staging sites you're authorized to reach.
  • --header — repeatable custom header. Useful for bearer tokens or environment hints like X-Environment: staging. Only send credentials to hosts you control or have written permission to access.

Crawl behavior

  • --sitemap — seed discovery from sitemap.xml, including nested sitemap indexes. Accepts a custom URL or a local file too.
  • --update — re-run against an existing mirror and skip resources whose ETag or Last-Modified hasn't changed. Ideal for recurring snapshots.
  • --render-js / --headless — route pages through a headless browser before parsing. Needed for client-rendered apps that ship an empty shell; keep it off otherwise because it's slower and always single-worker.

Output and reporting

  • --zip-output — bundle the finished mirror into a portable archive.
  • --warc-output — write response records in WARC format for archival workflows.
  • --manifest — emit a versioned JSON report of every resource's outcome (fetched, cached, skipped, failed), page titles and headings, and crawl stats. Handy when the mirror is part of a larger pipeline.
  • --progress — terminal dashboard for long crawls. Falls back to normal logging if the optional dependency isn't present.

A pragmatic starting point

website-downloader --url https://example.com --destination example_backup --max-pages 100 --delay 0.25 --respect-robots --manifest example_backup/crawl.json

Tune from there: drop --delay on hosts you own, raise --page-threads once you've confirmed the server is comfortable, and add --update on every subsequent run so unchanged assets are reused rather than re-fetched. If a crawl comes back looking thin, the usual culprits are a missing starting point (--url again) or a JS-rendered page that needs --render-js — check the manifest before assuming the site is empty.

Examples

Start with the smallest possible mirror: one page, its assets, and nothing else. Good for confirming your CLI flags parse the way you expect before pointing the tool at a larger site.

website-downloader --url https://example.com --destination example_backup --max-pages 1

Open example_backup/index.html and confirm assets resolve from disk. If they do, scale up page count and depth.

A typical docs archive — bounded, polite, and reproducible:

website-downloader ^
  --url https://example.com/docs/ ^
  --destination docs_backup ^
  --max-pages 200 ^
  --max-depth 3 ^
  --delay 0.25 ^
  --respect-robots

Deterministic limits matter here: --max-pages caps the total, --max-depth bounds link-hops from the seed, and --delay plus --respect-robots keep the request rate modest. Re-running the same command produces the same layout, which makes diffing two snapshots straightforward.

For sites assembled client-side, the default parser will only see an app shell. Switch to the rendering path:

website-downloader --url https://example.com --render-js --max-pages 20

--headless is an alias. Rendering is single-worker by design, so keep --max-pages modest for the first run and inspect what actually lands in the mirror before expanding.

Recurring archives should use update mode rather than re-downloading everything:

website-downloader ^
  --url https://example.com ^
  --destination example_backup ^
  --update ^
  --manifest example_backup/crawl.json

The manifest records which resources were downloaded, reused from cache, skipped, or failed. Point your scheduler at this command and diff the manifests between runs to spot churn.

Authorized portals and staging environments usually need session context. Pass cookies and headers explicitly:

website-downloader ^
  --url https://intranet.example.com ^
  --destination intranet_backup ^
  --cookie-file example-cookie.txt ^
  --header "X-Environment: staging"

Cookie files are plain header syntax (sessionid=abc123; csrftoken=xyz789). Keep them out of version control. The same flags work with a bearer token via --header "Authorization: Bearer <token>".

Multi-section sites are best handled with repeated seeds instead of a wide crawl from the root:

website-downloader ^
  --url https://example.com/docs/ ^
  --url https://example.com/blog/ ^
  --destination example_backup ^
  --max-depth 2

--url can be repeated or replaced with --url-file starting-urls.txt. Each seed gets its own depth budget, so --max-depth 2 means two hops from each starting point, not two hops overall.

Trim sections you don't want with glob patterns:

website-downloader ^
  --url https://example.com ^
  --destination example_backup ^
  --exclude "*/forum/*" ^
  --exclude "*/drafts/*"

Patterns match against both the full URL and the path, so /forum/* and */forum/* both work. For longer lists, --exclude-file exclude-patterns.txt reads one pattern per line.

Selected third-party assets can be localized with an allowlist:

website-downloader ^
  --url https://example.com ^
  --destination example_backup ^
  --download-external-assets ^
  --external-domains cdn.example.com fonts.gstatic.com

Localized assets land under cdn/<domain>/... and references are rewritten accordingly. Attributes like integrity and crossorigin are dropped where they would break the offline copy.

Export the finished mirror for storage or handoff:

website-downloader ^
  --url https://example.com ^
  --destination example_backup ^
  --zip-output example_backup.zip ^
  --warc-output example_backup.warc

Both exports run after the crawl completes, so they reflect exactly what landed on disk. Zip is convenient for transfer; WARC fits archival pipelines that expect response records.

A sitemap seed often discovers more pages with less crawling:

website-downloader --url https://example.com --sitemap --max-pages 500

Pass a specific sitemap URL or a local file as the value of --sitemap if the default location isn't where yours lives. Sitemap indexes are followed, so nested sitemaps resolve automatically.

When you need visibility on a long run, add the optional progress dashboard:

website-downloader --url https://example.com --progress

If the Rich dependency isn't present, the tool falls back to standard logging rather than failing the crawl.

A quick sanity pass after any run: open index.html from the mirror root, click through a few internal links, and check that styles and scripts load without network requests. If something is missing, the manifest is the fastest way to see whether a resource failed, was skipped by a filter, or was never discovered.

FAQ

Does this work on JavaScript-heavy sites?

Sometimes. The default parser sees what the server sends, so React/Vue/Next.js apps that build the DOM client-side will look like an empty shell. Install the optional render extra and pass --render-js (or its alias --headless) to run each page through a real browser first. It's slower and heavier, so only reach for it when a normal crawl comes back with missing links.

It missed images, fonts, or stylesheets. What now?

Check whether those assets live on a separate domain. Same-site assets are picked up by default; cross-origin CDN files need --download-external-assets plus an explicit --external-domains allowlist. Also glance at the manifest — skipped resources are listed there with the reason, which usually tells you whether it was a domain rule, a size cap (--max-asset-bytes), or an HTTP error.

Can I re-run it without re-downloading everything?

Yes — pass --update. The tool stores ETag and Last-Modified metadata and reuses local files when the server confirms they haven't changed. Servers that don't send validators will still get re-fetched, so the speedup depends on how the origin behaves.

How do I mirror a site that's behind a login?

Save the session cookies to a file in standard cookie-header syntax and pass --cookie-file. For token-based setups, --header "Authorization: Bearer <token>" works and can be repeated. Only do this for portals you're authorized to access, and keep those files out of version control.

Why is it so slow?

Sequential page fetching is the default on purpose — it keeps the crawl polite. Raise --page-threads if the target can take concurrent requests, add --delay if it can't, and leave --respect-robots on unless you have a specific reason not to. Large media files are usually the bottleneck, so cap them with --max-asset-bytes when you only need the text and layout.

The mirror opens but links are broken.

Most often this means the page used client-side routing or asset URLs the rewriter couldn't safely map. Re-run with --render-js so the real DOM is captured, and check the manifest for skipped resources. If the site pulls assets from a CDN, make sure that domain is in your external allowlist.

Can I limit the crawl to one section?

Use --exclude with glob patterns (*/forum/*, */drafts/*) or load a list with --exclude-file. Combine with --max-depth to stay close to your starting URLs, and --max-pages as a hard ceiling. Repeat --url or use --url-file when you want several entry points in one run.

Where do I find out what actually happened during a crawl?

Pass --manifest crawl.json. The report records every page and asset with its outcome — downloaded, cached, failed, or skipped — plus titles, headings, and HTTP status codes. It's the first place to look when something's missing, and it's structured for scripting against.

Does it run on Windows?

Yes. Paths are sanitized for reserved names, long paths are shortened, and query strings are hashed to avoid collisions. If you hit a path-length error, mirror to a shorter destination root rather than fighting the filesystem.

Can I get a single archive out of it?

Add --zip-output for a portable zip or --warc-output for a WARC response archive suitable for archival workflows. Both can be combined with --update for recurring snapshots.

Licensing and Responsible Use

This project is released under the MIT License. You are allowed to use, copy, modify, merge, publish, distribute, sublicense, and sell copies of the software, provided the original copyright notice and permission notice are included in all copies or substantial portions of the software. The software is provided "as is", without warranty of any kind, express or implied.

The copyright remains with the project author. The MIT license grants broad permission to use the code; it does not transfer ownership. The project name "Website Downloader" and any associated branding are not covered by the code license.

Responsible Use

Only mirror sites you own, have explicit permission to archive, or are otherwise legally permitted to access. Downloading a website does not grant you rights to its content — copyright, trademarks, and terms of service still apply.

A few practical ground rules:

  • Stay authorized. Point the script only at sites you control, sites with permissive terms, or sites where you have written permission to archive.
  • Keep credentials private. Cookie files and custom headers can expose session tokens and private content. Keep them out of source control, and never share mirrors that contain private data.
  • Be a polite client. Enable --respect-robots, keep --threads and --page-threads low, and set --delay on sites that don't tolerate concurrent requests. Hammering a server can get your IP blocked or disrupt service for others.
  • Respect asset limits. Use --max-asset-bytes to avoid pulling down large files you don't need, and --exclude to skip sections you have no reason to copy.
  • Treat mirrors as sensitive. A full local copy can contain private pages, internal links, and user data. Store, share, and delete mirrors accordingly.

If you're unsure whether a particular site permits local copying, check its terms or ask the site owner before running a crawl. When in doubt, don't download.

Disclaimer

This script is meant for mirroring sites you own, administer, or have explicit permission to copy — treat that as a hard requirement, not a footnote. Pointing it at anything else is a misuse of the tooling, and you're the one accountable for how you run it.

A few practical realities to keep in mind:

  • Access credentials travel with the tool. Cookie files and custom headers can unlock private content, so keep them out of version control, out of logs, and out of any mirror you share. If a mirror contains authenticated material, treat the output as sensitive by default.
  • Polite crawling is the default for a reason. Respect robots directives, keep concurrency low on sites you don't control, and introduce delays when hammering a server benefits nobody. Rate limits exist to be honored, not worked around.
  • Mirrored content keeps its original rights. Localizing pages, styles, and media doesn't change who owns them or what their licenses permit. Publishing or redistributing a mirror is a separate decision from making one.
  • Output is a snapshot, not a source of truth. Redirects, dynamic routes, and client-rendered pages may not survive the trip intact. Validate anything you plan to rely on before trusting it.

The authors and contributors of Website Downloader provide this script as-is, with no warranty of fitness for a particular purpose and no liability for how it's deployed. You choose the targets, you set the flags, and you own the outcome — including any consequences of crawling a site without the authority to do so.

Explorer des projets similaires

Chargement…