Skip to content

XenchinRyu7/Scrapture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Scrapture πŸ•·οΈ

License: MIT Next.js TypeScript Playwright PRs Welcome

Scrapture is a powerful, self-hosted web scraping framework built with Next.js, Playwright, and BullMQ. It features a beautiful neumorphism design dashboard for monitoring crawl jobs, viewing results, and managing configurations.

✨ Features

  • 🎨 Neumorphism UI - Beautiful, modern dashboard with dark mode support
  • πŸ€– Playwright Integration - Scrape SSR & CSR pages with auto-scroll support
  • πŸ“Š Job Queue System - BullMQ + Redis for reliable job processing
  • πŸ” API Response Capture - Automatically capture XHR/API responses
  • πŸ“Έ Screenshot Support - Take full-page screenshots
  • 🧠 AI Extraction - Optional Ollama integration for intelligent data extraction
  • βš™οΈ Domain Configs - Per-domain rate limiting, delays, and custom selectors
  • πŸ“ Real-time Logging - Monitor crawl progress with detailed logs
  • 🐳 Docker Ready - Complete Docker Compose setup
  • πŸ’» CLI Tool - Command-line interface for quick crawls

πŸ› οΈ Tech Stack

  • Frontend: Next.js 15, React 19, TypeScript, Tailwind CSS
  • Crawler: Playwright (Chromium)
  • Queue: BullMQ + Redis
  • Database: SQLite (default) or PostgreSQL
  • Charts: Recharts
  • State: Zustand
  • AI: Ollama (optional)

πŸš€ Quick Start

Prerequisites

  • Node.js 20+
  • Redis (or use Docker)
  • Ollama (optional, for AI extraction)

Installation

  1. Clone the repository
git clone <repository-url>
cd scrapture
  1. Install dependencies
npm install
  1. Setup environment
cp .env.example .env

Edit .env if needed:

DATABASE_URL="file:./dev.db"
REDIS_URL="redis://localhost:6379"
PORT=3000
NODE_ENV=development
OLLAMA_API_URL="http://localhost:11434"
  1. Initialize database
npm run db:push
npm run db:generate
  1. Install Playwright browsers
npx playwright install chromium

Running Locally

  1. Start Redis (if not using Docker)
redis-server
  1. Start the Next.js development server
npm run dev
  1. Start the worker (in a new terminal)
npm run worker
  1. Open the dashboard
http://localhost:3000

Docker Deployment

The easiest way to run Scrapture is with Docker Compose:

npm run docker:up

This will start:

  • Redis server
  • Next.js app (port 3000)
  • BullMQ worker

Stop services:

npm run docker:down

View logs:

npm run docker:logs

πŸ“– Usage

Dashboard

The main dashboard provides:

  • Quick job submission form
  • Real-time job statistics
  • Visual charts for job status
  • Navigation to all features

Jobs Management

View and monitor all crawl jobs:

  • Filter by status (pending, queued, running, completed, failed)
  • Click any job to see detailed results
  • Real-time updates every 3 seconds

Results Viewer

Browse completed crawls:

  • Thumbnail previews
  • Screenshot gallery
  • Extracted JSON data
  • API responses captured

Domain Configs

Create per-domain configurations:

  • Custom delays between requests
  • Concurrency limits
  • Rate limiting
  • Custom user agents
  • CSS selectors for data extraction
  • Enable AI extraction with Ollama

Logs Viewer

Monitor system logs:

  • Real-time log streaming
  • Filter by level (info, warn, error)
  • Job-specific logs
  • Timestamps and detailed messages

πŸ’» CLI Usage

Scrapture includes a powerful CLI for quick operations:

Queue a new crawl:

npm run cli crawl https://example.com

With options:

npm run cli crawl https://example.com --priority 10 --no-screenshot

View job statistics:

npm run cli status

πŸ”Œ API Endpoints

Jobs

  • GET /api/jobs - List all jobs (query: ?status=completed&limit=50)
  • POST /api/jobs - Create new crawl job
  • GET /api/jobs/[id] - Get job details
  • DELETE /api/jobs/[id] - Delete job

Stats

  • GET /api/stats - Get job statistics

Configs

  • GET /api/configs - List domain configs
  • POST /api/configs - Create new config
  • GET /api/configs/[id] - Get config
  • PUT /api/configs/[id] - Update config
  • DELETE /api/configs/[id] - Delete config

πŸ€– Ollama Integration

Scrapture can use Ollama for intelligent data extraction from HTML.

  1. Install Ollama
# Visit https://ollama.ai for installation
ollama pull llama2
  1. Enable in Domain Config
  • Go to Configs page
  • Create or edit a domain config
  • Check "Enable AI Extraction"
  • Add a custom prompt (e.g., "Extract product title, price, and description")
  1. Results
  • AI-extracted data will appear in job results
  • Look for aiExtracted field in JSON data

πŸ“ Project Structure

scrapture/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                # Next.js pages
β”‚   β”‚   β”œβ”€β”€ api/           # API routes
β”‚   β”‚   β”œβ”€β”€ jobs/          # Jobs pages
β”‚   β”‚   β”œβ”€β”€ configs/       # Config pages
β”‚   β”‚   β”œβ”€β”€ results/       # Results pages
β”‚   β”‚   └── logs/          # Logs pages
β”‚   β”œβ”€β”€ components/        # React components
β”‚   β”‚   β”œβ”€β”€ NeuCard.tsx
β”‚   β”‚   β”œβ”€β”€ NeuButton.tsx
β”‚   β”‚   β”œβ”€β”€ NeuInput.tsx
β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx
β”‚   β”‚   └── DarkModeToggle.tsx
β”‚   β”œβ”€β”€ lib/               # Core libraries
β”‚   β”‚   β”œβ”€β”€ crawler.ts     # Playwright crawler
β”‚   β”‚   β”œβ”€β”€ queue.ts       # BullMQ setup
β”‚   β”‚   └── db.ts          # Prisma client
β”‚   β”œβ”€β”€ types/             # TypeScript types
β”‚   └── generated/         # Prisma generated client
β”œβ”€β”€ prisma/
β”‚   └── schema.prisma      # Database schema
β”œβ”€β”€ public/
β”‚   └── screenshots/       # Captured screenshots
β”œβ”€β”€ worker.ts              # BullMQ worker process
β”œβ”€β”€ cli.ts                 # CLI tool
β”œβ”€β”€ docker-compose.yml     # Docker setup
β”œβ”€β”€ Dockerfile             # App container
└── Dockerfile.worker      # Worker container

🎨 Customization

Neumorphism Colors

Edit src/app/globals.css to customize the neumorphism theme:

:root {
  --background: #e0e5ec;
  --foreground: #2c3e50;
  --shadow-light: #ffffff;
  --shadow-dark: #a3b1c6;
}

[data-theme="dark"] {
  --background: #1a1a2e;
  --foreground: #eaeaea;
  --shadow-light: #252540;
  --shadow-dark: #0f0f1e;
}

🀝 Contributing

We love contributions! Please read our Contributing Guidelines to get started.

Ways to Contribute

  • πŸ› Report bugs and issues
  • πŸ’‘ Suggest new features
  • πŸ“ Improve documentation
  • πŸ”§ Submit pull requests
  • ⭐ Star the project if you find it useful!

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License - feel free to use this project for personal or commercial purposes.

πŸ™ Acknowledgments

οΏ½ Security

Security is important to us. If you discover a security vulnerability, please review our Security Policy for information on how to report it responsibly.

οΏ½πŸ“ž Support

For issues, questions, or contributions, please open an issue on GitHub.

Getting Help


Happy Scraping! πŸ•·οΈβœ¨

About

A web app for scraping website with high engine core to deepthly explore

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Sponsor this project

Packages

Contributors

Languages