{"id":29027505,"url":"https://github.com/pkharsimran/website-downloader","last_synced_at":"2026-03-01T16:01:18.991Z","repository":{"id":251340452,"uuid":"823845627","full_name":"PKHarsimran/website-downloader","owner":"PKHarsimran","description":"Website-downloader is a powerful and versatile Python script designed to download entire websites along with all their assets. This tool allows you to create a local copy of a website, including HTML pages, images, CSS, JavaScript files, and other resources. It is ideal for web archiving, offline browsing, and web development.","archived":false,"fork":false,"pushed_at":"2026-03-01T00:19:55.000Z","size":95,"stargazers_count":107,"open_issues_count":1,"forks_count":23,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-03-01T03:43:22.677Z","etag":null,"topics":["automation","beautifulsoup","data-mining","html","internet-tools","offline-browsing","open-source","python","python-scripts","requests","web-archiving","web-scraping","website-cloner","website-downloader","wget"],"latest_commit_sha":null,"homepage":"https://harsim.ca/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PKHarsimran.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-03T20:59:45.000Z","updated_at":"2026-03-01T00:19:53.000Z","dependencies_parsed_at":"2024-08-02T10:45:47.691Z","dependency_job_id":"a887fcb3-01da-4b3f-9096-9aa871941f0c","html_url":"https://github.com/PKHarsimran/website-downloader","commit_stats":null,"previous_names":["pkharsimran/website-downloader"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/PKHarsimran/website-downloader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PKHarsimran%2Fwebsite-downloader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PKHarsimran%2Fwebsite-downloader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PKHarsimran%2Fwebsite-downloader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PKHarsimran%2Fwebsite-downloader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PKHarsimran","download_url":"https://codeload.github.com/PKHarsimran/website-downloader/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PKHarsimran%2Fwebsite-downloader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29974321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T15:41:30.362Z","status":"ssl_error","status_checked_at":"2026-03-01T15:37:07.343Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","beautifulsoup","data-mining","html","internet-tools","offline-browsing","open-source","python","python-scripts","requests","web-archiving","web-scraping","website-cloner","website-downloader","wget"],"created_at":"2025-06-26T06:30:35.423Z","updated_at":"2026-03-01T16:01:18.975Z","avatar_url":"https://github.com/PKHarsimran.png","language":"Python","funding_links":["https://www.paypal.com/donate/?business=MVEWG3QAX6UBC\u0026no_recurring=1\u0026item_name=Github+Project+-+Website+downloader\u0026currency_code=CAD"],"categories":[],"sub_categories":[],"readme":"# 🌐 Website Downloader CLI  \n\n[![CI – Website Downloader](https://github.com/PKHarsimran/website-downloader/actions/workflows/python-app.yml/badge.svg)](https://github.com/PKHarsimran/website-downloader/actions/workflows/python-app.yml)\n[![Lint \u0026 Style](https://github.com/PKHarsimran/website-downloader/actions/workflows/lint.yml/badge.svg)](https://github.com/PKHarsimran/website-downloader/actions/workflows/lint.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python](https://img.shields.io/badge/Python-3.10%2B-blue.svg)](https://www.python.org/)\n[![Code style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nWebsite Downloader CLI is a lightweight, pure-Python site mirroring tool that creates a fully browsable offline copy of any publicly accessible website.\n\n* Recursively crawls every same-origin link (including “pretty” `/about/` URLs)\n* Downloads **all** assets (images, CSS, JS, …)\n* Rewrites internal links so pages open flawlessly from your local disk\n* Streams files concurrently with automatic retry / back-off\n* Generates a clean, flat directory tree (`example_com/index.html`, `example_com/about/index.html`, …)\n* Handles extremely long filenames safely via hashing and graceful fallbacks\n\n\u003e Perfect for web archiving, pentesting labs, long flights, or just poking around a site without an internet connection.\n\n\n## ❤️ Support This Project\n\nIf you find this tool useful, consider supporting the project:\n\n[Donate via\nPayPal](https://www.paypal.com/donate/?business=MVEWG3QAX6UBC\u0026no_recurring=1\u0026item_name=Github+Project+-+Website+downloader\u0026currency_code=CAD)\n\n---\n\n## 🚀 Quick Start\n\n```bash\n# 1. Grab the code\ngit clone https://github.com/PKHarsimran/website-downloader.git\ncd website-downloader\n\n# 2. Install dependencies (only two runtime libs!)\npip install -r requirements.txt\n\n# 3. Mirror a site – no prompts needed\npython website-downloader.py \\\n    --url https://harsim.ca \\\n    --destination harsim_ca_backup \\\n    --max-pages 100 \\\n    --threads 8\n```\n\n---\n\n## 🛠️ Libraries Used\n\n| Library | Purpose |\n|----------|----------|\n| **requests** + **urllib3.Retry** | HTTP client with automatic retry, backoff, and persistent session handling |\n| **BeautifulSoup (bs4)** | Parses HTML and extracts `\u003ca\u003e`, `\u003cimg\u003e`, `\u003cscript\u003e`, and `\u003clink\u003e` elements |\n| **argparse** | Provides structured CLI argument parsing and validation |\n| **logging** | Dual console + file logging with crawl progress and summary metrics |\n| **threading** \u0026 **queue** | Concurrent asset downloading via lightweight worker pool |\n| **pathlib** \u0026 **os** | Cross-platform filesystem management and safe directory creation |\n| **urllib.parse** | URL parsing, normalization, and safe internal link rewriting |\n| **hashlib (sha256)** | Generates stable hashes for long filenames and query-string collisions |\n| **posixpath** | Normalizes URL paths while preventing traversal |\n| **time** | Measures crawl duration and per-page performance |\n| **sys** | Handles CLI exit codes and stream output management |\n| **re** | Normalizes path segments and collapses malformed multi-dot filenames |\n\n## 🗂️ Project Structure\n\n| Path | What it is | Key features |\n|------|------------|--------------|\n| `website_downloader.py` | **Single-entry CLI** that performs the entire crawl *and* link-rewriting pipeline. | • Persistent `requests.Session` with automatic retries\u003cbr\u003e• Breadth-first crawl capped by `--max-pages` (default = 50)\u003cbr\u003e• Thread-pool (configurable via `--threads`, default = 6) to fetch images/CSS/JS in parallel\u003cbr\u003e• Robust link rewriting so every internal URL works offline (pretty-URL folders ➜ `index.html`, plain paths ➜ `.html`)\u003cbr\u003e• Smart output folder naming (`example.com` → `example_com`)\u003cbr\u003e• Colourised console + file logging with per-page latency and crawl summary |\n| `requirements.txt` | Minimal dependency pin-list. Only **`requests`** and **`beautifulsoup4`** are third-party; everything else is Python ≥ 3.10 std-lib. |\n| `web_scraper.log` | Auto-generated run log (rotates/overwrites on each invocation). Useful for troubleshooting or audit trails. |\n| `README.md` | The document you’re reading – quick-start, flags, and architecture notes. |\n| *(output folder)* | Created at runtime (`example_com/ …`) – mirrors the remote directory tree with `index.html` stubs and all static assets. |\n\n\u003e **Removed:** The old `check_download.py` verifier is no longer required because the new downloader performs integrity checks (missing files, broken internal links) during the crawl and reports any issues directly in the log summary.\n\n## ✨ Recent Improvements\n\n✅ Type Conversion Fix\nFixed a TypeError caused by int(..., 10) when non-string arguments were passed.\n\n✅ Safer Path Handling\nAdded intelligent path shortening and hashing for long filenames to prevent\nOSError: [Errno 36] File name too long errors.\n\n✅ Improved CLI Experience\nRebuilt argument parsing with argparse for cleaner syntax and validation.\n\n✅ Code Quality \u0026 Linting\nApplied Black + Flake8 formatting; the project now passes all CI lint checks.\n\n✅ Logging \u0026 Stability\nImproved error handling, logging, and fallback mechanisms for failed writes.\n\n✅ Skip Non-Fetchable Schemes  \nThe crawler now safely skips `mailto:`, `tel:`, `javascript:`, and `data:` links instead of trying to download them.  \nThis prevents `requests.exceptions.InvalidSchema: No connection adapters were found` errors and keeps those links intact in saved HTML.\n\n✅ Improved Path Normalization\n-   Decodes URL-encoded segments (`%20` → space)\n-   Trims unnecessary whitespace\n-   Collapses accidental multi-dot filenames (`file....jpg` →\n    `file.jpg`)\n-   Preserves traversal protection and hashing safeguards\n\n------------------------------------------------------------------------\n\n\n## 🤝 Contributing\n\nContributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.\n\n## 📜 License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkharsimran%2Fwebsite-downloader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkharsimran%2Fwebsite-downloader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkharsimran%2Fwebsite-downloader/lists"}