Skip to content
Proyectos

popo4512/SiteMirror-Lite

Ver en GitHub

Acerca de

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]

Aprendizaje y educación

Cómo se miden estas cifras

What you can do

  • 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]

Crecimiento de estrellas medido

in 24h
0
in 7 days
0
in 15 days
+6
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

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 with EventSource and 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:

  • express for HTTP server
  • axios for HTTP requests
  • cheerio for HTML parsing and scraping
  • archiver for ZIP creation
  • uuid for 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:

http://localhost:3000

text


🧭 Usage

  1. Open the homepage in your browser.
  2. Enter the target website URL, e.g. https://example.com.
  3. Optionally set the maximum crawl depth:
    • 0 = only the start page
    • 1 = start page + its direct children, and so on.
  4. Click “Start” to send a POST /api/tasks request that creates a new task and returns a task ID.
  5. The frontend subscribes to /api/tasks/:id/events using EventSource to receive live updates (downloaded pages, assets, errors, status), matching documented patterns for SSE with Express and EventSource clients.[web:33][web:51]
  6. 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:

  1. Fork this repository.
  2. Create a feature branch: git checkout -b feature/your-feature.
  3. Commit your changes: git commit -m "Add some feature".
  4. Push the branch: git push origin feature/your-feature.
  5. 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]

Explorar proyectos relacionados

Cargando…