popo4512/SiteMirror-Lite
حول
A lightweight website mirroring tool: given a website URL, the backend crawls pages and static assets, rewrites links to local paths, and packages everything into a ZIP file for download. The stack is Node.js + Express + Cheerio + Archiver, similar to typical Node-based scraping and zipping workflows commonly documented in web scraping and ZIP-handling tutorials.[web:31][web:24]
التعلّم والتعليمما يمكنك فعله
- Scoped site crawl (bounded depth)Uses Axios to request pages and Cheerio to parse HTML and extract internal links, with configurable maximum crawl depth and page count, following widely used Cheerio scraping patterns.[web:31][web:43]
- Static asset collection and localizationAutomatically discovers CSS, JS, image, and other static resources referenced in HTML and maps URLs to local file paths, producing a clean offline-ready directory, as recommended in practical Cheerio-based scraping guides.[web:42][web:50]
- ZIP packaging and downloadAfter crawling, the backend uses Archiver to compress the target directory into a ZIP and streams it back to the browser via a download endpoint, mirroring common Node.js ZIP-generation examples.[web:24][web:52]
- Realtime progress via SSEExposes a Server-Sent Events endpoint so the frontend can subscribe with EventSource and receive live task updates (status, counts, errors), following established Express SSE patterns.[web:33][web:51]
النمو المقاس للنجوم
- خلال 24 ساعة
- -١
- خلال 7 أيام
- ٠
- خلال 15 يومًا
- +٦
- خلال شهر
- التحديث متأخر
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصلSiteMirror Lite
A lightweight website mirroring tool: given a website URL, the backend crawls pages and static assets, rewrites links to local paths, and packages everything into a ZIP file for download. The stack is Node.js + Express + Cheerio + Archiver, similar to typical Node-based scraping and zipping workflows commonly documented in web scraping and ZIP-handling tutorials.[web:31][web:24]
✨ Features
Scoped site crawl (bounded depth)
Uses Axios to request pages and Cheerio to parse HTML and extract internal links, with configurable maximum crawl depth and page count, following widely used Cheerio scraping patterns.[web:31][web:43]Static asset collection and localization
Automatically discovers CSS, JS, image, and other static resources referenced in HTML and maps URLs to local file paths, producing a clean offline-ready directory, as recommended in practical Cheerio-based scraping guides.[web:42][web:50]ZIP packaging and download
After crawling, the backend uses Archiver to compress the target directory into a ZIP and streams it back to the browser via a download endpoint, mirroring common Node.js ZIP-generation examples.[web:24][web:52]Realtime progress via SSE
Exposes a Server-Sent Events endpoint so the frontend can subscribe withEventSourceand receive live task updates (status, counts, errors), following established Express SSE patterns.[web:33][web:51]
📁 Project Structure
SiteMirror-Lite/ ├── server.js # App entry, HTTP server + route mounting ├── config.js # Core configuration (port, depth limits, timeouts, dirs) ├── routes.js # REST API and SSE route definitions ├── crawler.js # Crawling + link parsing logic (Axios + Cheerio) ├── archiver.js # Directory-to-ZIP packaging (Archiver) ├── progress-store.js # In-memory task state management ├── public/ │ ├── index.html # Single-page frontend (vanilla JS + EventSource) │ └── style.css # Minimal styling ├── package.json # Project metadata and dependencies └── README.md # Project documentation
text
At runtime, the service creates a data directory if needed:
data/ ├── tasks/ # Per-task crawl output directories └── zips/ # Completed task ZIP archives
text
🚀 Getting Started
1. Prerequisites
- Node.js 18 or newer
- npm, pnpm, or yarn (examples below use npm)
2. Install dependencies
git clone sitemirror-lite cd sitemirror-lite npm install
text
Key dependencies defined in package.json are:
expressfor HTTP serveraxiosfor HTTP requestscheeriofor HTML parsing and scrapingarchiverfor ZIP creationuuidfor task IDs
These match common stacks used in Cheerio web-scraping and Node ZIP tutorials.[web:31][web:24][web:32]
3. Start the server
npm start
text
By default, the app listens on the port configured in config.js (e.g., 3000):
// config.js (excerpt) module.exports = { port: 3000, maxDepth: 2, maxPages: 200, maxTotalBytes: 50 * 1024 * 1024, requestTimeout: 10000, maxConcurrentRequests: 5, dataRoot: './data', tasksDir: './data/tasks', zipsDir: './data/zips' };
text
Then open in your browser:
text
🧭 Usage
- Open the homepage in your browser.
- Enter the target website URL, e.g.
https://example.com. - Optionally set the maximum crawl depth:
0= only the start page1= start page + its direct children, and so on.
- Click “Start” to send a
POST /api/tasksrequest that creates a new task and returns a task ID. - The frontend subscribes to
/api/tasks/:id/eventsusingEventSourceto receive live updates (downloaded pages, assets, errors, status), matching documented patterns for SSE with Express and EventSource clients.[web:33][web:51] - When the task status becomes
finished, a “Download ZIP” button appears, linking to/api/tasks/:id/download, which streams the ZIP archive to the browser.
The crawl and parsing flow follows common Cheerio-based scraping examples where HTML content is fetched, parsed, and links are followed within controlled bounds.[web:42][web:55]
🧩 API Overview
POST /api/tasks
Create a new crawl task.
- Request body:
{ "url": "https://example.com", "depth": 2 }
text
- Response:
{ "taskId": "b6f4c3e0-..." }
text
GET /api/tasks/:id
Get task details and progress.
- Example response:
{ "id": "b6f4c3e0-...", "status": "running", "progress": { "downloadedPages": 5, "downloadedAssets": 32, "errors": 1 }, "zipPath": null }
text
GET /api/tasks/:id/download
When the task is finished, returns the ZIP file as the HTTP response body for download.
GET /api/tasks/:id/events (SSE)
Streams realtime task updates using Server-Sent Events.
- Client example:
const es = new EventSource(/api/tasks/${taskId}/events); es.onmessage = (event) => { const task = JSON.parse(event.data); // Update progress UI };
text
This pattern mirrors established Express SSE examples where the server sets text/event-stream headers and pushes JSON-encoded messages.[web:33][web:51]
⚙️ Limits and Configuration
To avoid abuse and excessive resource usage, adjust limits in config.js:
- Maximum crawl depth and max page count
- Per-task total byte limit
- Request timeout and max concurrent requests
Additionally, you should strictly restrict crawls to the same origin as the start URL by normalizing and filtering URLs, as recommended in responsible scraping practices.[web:53][web:50]
🤝 Contributing
Contributions are welcome:
- Fork this repository.
- Create a feature branch:
git checkout -b feature/your-feature. - Commit your changes:
git commit -m "Add some feature". - Push the branch:
git push origin feature/your-feature. - Open a Pull Request on GitHub.
📄 License
The project is intended to be licensed under the MIT License. Add a LICENSE file at the repository root and adjust terms as needed following common open source licensing practices.[web:32]
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…