-
Notifications
You must be signed in to change notification settings - Fork 2
How It Works
Uncage clones websites by launching a real browser (Chromium via Playwright), loading each page, intercepting every network request, and saving the results as static files. The output is a self-contained folder that can be opened directly in a browser or deployed to any static host.
The cloning process runs in this order:
A headless Chromium browser starts up using Playwright with stealth plugins. The stealth plugins prevent the browser from being detected as automated, which avoids getting blocked by anti-bot systems.
The crawler visits the seed URL first. It then discovers links on that page and adds them to a queue. Each link is visited in turn, up to the configured depth and page limits.
Before crawling, the tool checks robots.txt (unless told to ignore it) to respect the site's crawling rules. If a sitemap is available, it uses that to discover pages as well.
While each page loads, every network request is intercepted. The tool looks at each response and sorts it by content type:
- HTML is saved as page files.
-
CSS goes to
assets/css/. -
JavaScript goes to
assets/js/. -
Images go to
assets/images/. -
Fonts go to
assets/fonts/. -
Other files (video, WASM, JSON) go to their respective folders under
assets/.
All URLs in the saved HTML and CSS files are rewritten to point to local paths instead of remote servers. For example, https://cdn.example.com/style.css becomes assets/css/style-abc123.css.
This step also handles:
- Relative URLs
- CSS
url()references - Inline styles
- srcset attributes on images
Modern websites use JavaScript modules that import other modules. The tool scans each downloaded JS file for import statements and dynamically imported modules, then downloads those dependencies too. This continues recursively until all dependencies are resolved.
Each crawled page's HTML is processed:
- Duplicate meta tags and title tags are removed.
- Analytics and tracking scripts are stripped (unless
--keep-analyticsis set). - Internal links between pages are rewritten to point to the correct local HTML files.
PurgeCSS runs over the CSS files and removes any classes that are not used in the HTML. This reduces file size. This step can be skipped with --no-purge if it removes classes that are added dynamically by JavaScript.
During crawling, assets are saved under public/assets/. In this final step, they are moved to the root assets/ directory for a cleaner structure.
The tool generates:
- A
package.jsonwith apreviewscript. - A
README.mdwith basic instructions. - An
asset-map.jsonthat maps original URLs to local file paths.
output/example.com/
index.html
about.html
contact.html
assets/
css/
js/
images/
fonts/
media/
wasm/
data/
asset-map.json
package.json
README.md