A Python demo showcasing browser automation, video recording, and website cloning using Playwright.
- Automated browser navigation with Chromium
- Video recording of browser sessions
- Full-page screenshot capture
- Website Cloner - Extract any website and generate a high-fidelity React replica
- Comparison Videos - Record side-by-side videos of cloned vs original sites
pip install -r requirements.txt
playwright install chromiumClone any website into a local React application:
python -m website_cloner https://example.comOptions:
-o, --output- Output directory (default:./output)-n, --name- Project name (default: domain name)-m, --mode- Clone mode:fullorshallow(default:full)--no-download-assets- Skip downloading images/fonts
Clone Modes:
full- Extracts actual CSS files, preserves media queries, hover states, and animationsshallow- Extracts computed styles (faster but loses responsive design)
Example:
# High-fidelity clone (recommended)
python -m website_cloner https://www.apple.com --mode full
# Quick clone with computed styles
python -m website_cloner https://www.apple.com --mode shallowThen run the cloned site:
cd output/www-apple-com
npm install
npm run devOpen http://localhost:5173 to view the replica.
What it clones:
- HTML structure with proper JSX conversion
- CSS stylesheets (media queries, hover states, animations)
- Images and fonts (downloaded locally)
- srcset responsive images
- Mock interactions (buttons log to console, forms show alerts)
Record videos comparing cloned and original sites:
python compare_sites.pyOptions:
--clone-url URL- URL of cloned site (default: http://localhost:5173)--original-url URL- URL of original site (default: https://www.apple.com)-o, --output DIR- Output directory (default: ./videos/comparison)--headless- Run browser in headless mode--no-scroll- Disable scrolling during recording--clone-only- Only record the cloned site--original-only- Only record the original site
Example:
# Record both sites
python compare_sites.py
# Custom URLs
python compare_sites.py --clone-url http://localhost:5175 --original-url https://www.apple.com
# Headless mode
python compare_sites.py --headlessOutput:
cloned-site.webm- Video with scrollingcloned-site.png- Full-page screenshotoriginal-site.webm- Video with scrollingoriginal-site.png- Full-page screenshot
python demo_browser.pyThis will:
- Launch a visible Chromium browser
- Navigate to example.com and news.ycombinator.com
- Capture a screenshot (
last-page.png) - Save the session recording to
videos/
videos/- Recorded browser session videosvideos/comparison/- Comparison videos (cloned vs original)output/- Generated React projects from website cloner
browser-use-demo/
├── website_cloner/ # Website cloning module
│ ├── extractor/ # Page and CSS extraction
│ ├── transformer/ # HTML to JSX conversion
│ └── generator/ # React project generation
├── compare_sites.py # Comparison video recorder
├── demo_browser.py # Browser recording demo
└── output/ # Generated cloned sites