Skip to content

sheikh-bilal/web-scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” Web Scraper Dashboard

A modern, real-time web scraping dashboard for extracting data from Google Maps and YouTube. Features a beautiful React frontend with live progress updates, analytics charts, and export functionality.

✨ Features

Core Functionality

  • πŸ“Š Real-Time Dashboard - Watch data arrive live as it's scraped via WebSocket
  • πŸ“ˆ Analytics Charts - Visual insights with Recharts
  • πŸŒ™ Dark/Light Mode - Easy theme toggle with persistence
  • πŸ“€ Export Options - Excel, CSV, and JSON export
  • πŸ”„ Multiple Concurrent Sessions - Run multiple scrapers simultaneously

Scrapers

Scraper Modes Data Points
πŸ—ΊοΈ Google Maps Search Name, address, phone, website, rating, reviews, social links
πŸŽ₯ YouTube Search, Trending, Suggestions, Deep Metadata Title, views, likes, duration, uploader, tags, categories, description

UI/UX

  • 🎨 Premium Design - Glass morphism, gradients, smooth animations
  • πŸ“± Fully Responsive - Works on desktop, tablet, and mobile
  • β™Ώ Accessible - ARIA labels, keyboard navigation support
  • πŸ”” Real-Time Notifications - Toast notifications for all events
  • ⚑ Fast Performance - Optimized React rendering, virtual scrolling ready

πŸ—οΈ Architecture

web-scraper/
β”œβ”€β”€ backend/                    # Node.js + Express + Socket.io
β”‚   β”œβ”€β”€ server.js              # Main server with graceful shutdown
β”‚   β”œβ”€β”€ scrapers/              # Async generator scrapers
β”‚   β”‚   β”œβ”€β”€ google.js          # Google Maps scraper
β”‚   β”‚   └── youtube.js         # YouTube scraper (4 modes)
β”‚   β”œβ”€β”€ controllers/           # API handlers
β”‚   β”‚   β”œβ”€β”€ googleController.js
β”‚   β”‚   └── youtubeController.js
β”‚   β”œβ”€β”€ routes/                # API endpoints
β”‚   β”‚   └── scrapers.js
β”‚   └── utils/                 # Utilities
β”‚       β”œβ”€β”€ sessionManager.js  # Session state management
β”‚       β”œβ”€β”€ browserManager.js  # Puppeteer browser tracking
β”‚       β”œβ”€β”€ logger.js          # Winston logging
β”‚       └── errorHandler.js    # Error classification
β”‚
β”œβ”€β”€ frontend/                   # React + Vite + Tailwind
β”‚   └── src/
β”‚       β”œβ”€β”€ components/        # React components
β”‚       β”‚   β”œβ”€β”€ ScraperSelector.jsx
β”‚       β”‚   β”œβ”€β”€ GoogleForm.jsx
β”‚       β”‚   β”œβ”€β”€ YouTubeForm.jsx
β”‚       β”‚   β”œβ”€β”€ ProgressBar.jsx
β”‚       β”‚   β”œβ”€β”€ ResultsTable.jsx
β”‚       β”‚   β”œβ”€β”€ Charts.jsx
β”‚       β”‚   β”œβ”€β”€ ExportButtons.jsx
β”‚       β”‚   β”œβ”€β”€ ActiveSessions.jsx
β”‚       β”‚   └── ThemeToggle.jsx
β”‚       β”œβ”€β”€ context/           # Global state
β”‚       β”‚   └── ScraperContext.jsx
β”‚       └── styles/            # Tailwind CSS + custom animations
β”‚
β”œβ”€β”€ scrapers/                   # Legacy CLI scrapers
└── output/                     # Exported data

πŸ”§ Requirements

  • Node.js v18+ (with ES modules support)
  • npm v9+
  • yt-dlp (for YouTube metadata extraction)

Install yt-dlp:

# macOS
brew install yt-dlp

# Linux
sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
sudo chmod a+rx /usr/local/bin/yt-dlp

# Windows
choco install yt-dlp

πŸš€ Quick Start

1. Clone and Install

# Clone the repository
git clone <repo-url>
cd web-scraper

# Install backend dependencies
cd backend
npm install

# Install frontend dependencies
cd ../frontend
npm install

2. Configure Environment

Backend (backend/.env):

NODE_ENV=development
PORT=3000
FRONTEND_URL=http://localhost:5173

Frontend (frontend/.env):

VITE_API_URL=http://localhost:3000

3. Start the Servers

Terminal 1 - Backend:

cd backend
npm start

Server runs on http://localhost:3000

Terminal 2 - Frontend:

cd frontend
npm run dev

Dashboard opens on http://localhost:5173

4. Stop the Servers

Press Ctrl+C in the terminal. The server will:

  • Cancel all running scraping sessions
  • Close all Puppeteer browser instances
  • Close Socket.io connections
  • Exit gracefully within 10 seconds

πŸ“– Usage

Web Dashboard

  1. Open http://localhost:5173
  2. Select a scraper (Google Maps or YouTube)
  3. Configure options:
    • Google Maps: Search term, headless mode, max results
    • YouTube: Mode, search term/country, content filter
  4. Start scraping and watch real-time results
  5. View analytics charts automatically update
  6. Export to Excel/CSV/JSON when complete

Google Maps Scraper

Configuration:

  • Search Term (required) - e.g., "Restaurants in New York"
  • Headless Mode - Run browser without UI (default: true)
  • Max Results - Limit number of results (optional)

Data Extracted:

{
  name: "Business Name",
  address: "123 Main St",
  phone: "+1 234 567 8900",
  website: "https://example.com",
  rating: "4.5",
  reviews: "123",
  fb: "facebook.com/page",
  insta: "instagram.com/page",
  linkedln: "linkedin.com/company",
  url: "maps.google.com/..."
}

YouTube Scraper

Modes:

  1. Search - Search videos by keyword

    • Input: Search term
    • Results: Video list with views, duration, channel
  2. Trending - Get trending videos by country

    • Input: Country code, content filter (all/videos/shorts)
    • Results: Trending videos with metadata
  3. Suggestions - Get autocomplete suggestions

    • Input: Query term
    • Results: Suggestion list
  4. Deep Metadata - Get full video metadata

    • Input: Video URL
    • Results: Complete metadata including tags, categories, description

Data Extracted:

{
  title: "Video Title",
  url: "https://youtube.com/watch?v=...",
  views: 1234567,
  likes: 45678,
  duration: 627,           // seconds
  upload_date: "20240115",
  tags: ["tag1", "tag2"],
  categories: ["Entertainment"],
  description: "Video description...",
  uploader: "Channel Name",
  thumbnail: "https://..."
}

πŸ“‘ API Reference

Scraping Endpoints

POST /api/scrape/google
Body: { searchTerm, headless?, maxResults? }

POST /api/scrape/youtube
Body: { mode, searchTerm?, countryCode?, filterType?, headless? }

Session Management

GET    /api/scrape/active           # List all active sessions
GET    /api/scrape/status/:id       # Get session status
DELETE /api/scrape/:id              # Cancel a session

Export

GET /api/scrape/:sessionId/export?format=excel|csv|json

WebSocket Events

Client β†’ Server:

socket.emit('scrape:start', { scraperType, config })
socket.emit('scrape:cancel', { sessionId })
socket.emit('session:join', { sessionId })

Server β†’ Client:

socket.on('session:started', { sessionId, scraperType, startTime })
socket.on('scrape:progress', { sessionId, progress })
socket.on('scrape:data', { sessionId, data })
socket.on('scrape:batch', { sessionId, data })
socket.on('session:complete', { sessionId, totalItems, duration })
socket.on('session:error', { sessionId, error })
socket.on('session:cancelled', { sessionId })
socket.on('sessions:active', { sessions })

πŸ› οΈ Tech Stack

Backend

Technology Purpose
Express.js Web framework
Socket.io Real-time WebSocket communication
Puppeteer Headless browser automation
yt-search YouTube search API
yt-dlp YouTube metadata extraction
Winston Logging
UUID Session ID generation
ExcelJS Excel export

Frontend

Technology Purpose
React 18 UI framework
Vite Build tool and dev server
Tailwind CSS Styling
Recharts Data visualization
Socket.io-client WebSocket client
axios HTTP requests
react-hot-toast Notifications

βš™οΈ Configuration

Browser Options

Puppeteer launch options (in scrapers):

{
  headless: true,                    // Run without UI
  args: [
    '--no-sandbox',                  // Required for Linux
    '--disable-setuid-sandbox',      // Security
    '--disable-dev-shm-usage'        // Memory optimization
  ]
}

Session Limits

  • Max items per session: 10,000
  • Session retention: 24 hours
  • Auto-cleanup: Every hour

πŸ”’ Environment Variables

Variable Default Description
NODE_ENV development Environment mode
PORT 3000 Backend server port
FRONTEND_URL http://localhost:5173 CORS origin
VITE_API_URL http://localhost:3000 Backend API URL

πŸ› Troubleshooting

Backend won't start

# Check if port 3000 is in use
lsof -i :3000
# Kill the process or change PORT in .env

Puppeteer errors

# Install required dependencies
# Ubuntu/Debian
sudo apt-get install -y \
  chromium-browser \
  fonts-liberation \
  fonts-noto-color-emoji \
  fonts-ipafont-gothic \
  fonts-wqy-zenhei \
  fonts-thai-tlwg \
  fonts-kacst \
  fonts-freefont-ttf

# macOS
# No additional dependencies needed

YouTube metadata missing

# Verify yt-dlp installation
yt-dlp --version

# Update yt-dlp
yt-dlp --update

Ctrl+C not stopping server

  • The graceful shutdown waits up to 10 seconds for browsers to close
  • Force quit: Press Ctrl+C twice or Ctrl+\

Frontend not connecting to backend

  • Check VITE_API_URL in frontend .env
  • Check FRONTEND_URL in backend .env
  • Ensure backend is running on correct port

πŸ“Š License

This project is intended for educational and research purposes only.

Terms of Service Compliance

Ensure you comply with the Terms of Service of:

Usage Guidelines

  • Respect rate limits - Add delays between requests
  • Don't overload servers - Use reasonable concurrent sessions
  • Attribution - Credit data sources appropriately
  • Legal compliance - Follow local laws and regulations

πŸ‘¨πŸ»β€πŸ’» Developer

Bilal Ahmed

πŸ™ Acknowledgments

  • yt-search - YouTube search library
  • Puppeteer - Headless Chrome automation
  • Vite - Next-gen frontend tooling
  • Tailwind CSS - Utility-first CSS framework

About

Web Scraper

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors