Multi-agent browser automation framework based on page-agent. Uses DOM-based manipulation for fast and reliable web interaction.
- π€ Multi-Agent Workflow: Planner β Browser Agent β Extractor pipeline
- π DOM-Based: Direct DOM manipulation (no screenshots needed)
- π― Flexible: Works in user's real browser or headless
- β‘ Fast: Direct DOM operations, no image processing
- π Caching: Built-in result caching for performance
- π MCP Server: External control via Model Context Protocol
- π¨ Full Toolset: All page-agent tools enabled (javascript, user interaction, etc.)
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β PLANNER ββββββΆβ SCRAPER ββββββΆβ EXTRACTOR β
β (qwen3.5) β β (glm-5.1) β β (gemini) β
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β
βΌ
ββββββββββββββββ
β PAGE-AGENT β
β (DOM-based) β
ββββββββββββββββ
β
βΌ
ββββββββββββββββ
β BROWSER β
β (User's) β
ββββββββββββββββ
# Clone repository
git clone https://github.com/mamidevs/browser-scraper.git
cd browser-scraper
# Install dependencies
npm install
# Setup environment variables
cp .env.example .env
# Edit .env and add your OpenRouter API keyCreate .env file:
# OpenRouter API Key
OPENROUTER_API_KEY=your_api_key_here
# Model Configuration (optional - defaults shown)
PLANNER_MODEL=qwen/qwen3.5-27b
SCRAPER_MODEL=z-ai/glm-5.1
EXTRACTOR_MODEL=google/gemini-2.5-flash
# Base URL (optional)
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1import { ScrapingAgent } from 'browser-scraper';
const agent = new ScrapingAgent({
model: 'z-ai/glm-5.1',
apiKey: process.env.OPENROUTER_API_KEY,
});
await agent.initialize();
// Navigate and extract
await agent.navigate('https://example.com');
const result = await agent.execute('Extract all product names and prices');
console.log(result.data);import { ScrapingOrchestrator } from 'browser-scraper';
const orchestrator = new ScrapingOrchestrator({
planner: { model: 'qwen/qwen3.5-27b', apiKey: '...' },
scraper: { model: 'z-ai/glm-5.1', apiKey: '...' },
extractor: { model: 'google/gemini-2.5-flash', apiKey: '...' },
});
await orchestrator.initialize();
const result = await orchestrator.scrape({
task: 'Find all laptops under $1000 with ratings above 4.0',
url: 'https://amazon.com',
schema: {
type: 'array',
items: {
type: 'object',
properties: {
name: { type: 'string' },
price: { type: 'number' },
rating: { type: 'number' }
}
}
}
});
console.log('Plan:', result.plan);
console.log('Data:', result.data);const urls = [
'https://example.com/page1',
'https://example.com/page2',
'https://example.com/page3',
];
const results = await orchestrator.scrapeBatch(
urls.map(url => ({
task: 'Extract product names and prices',
url,
schema: { /* ... */ }
})),
3 // concurrency
);import { ScrapingMCPServer } from 'browser-scraper';
const server = new ScrapingMCPServer();
await server.initialize({
planner: { model: 'qwen/qwen3.5-27b', apiKey: '...' },
scraper: { model: 'z-ai/glm-5.1', apiKey: '...' },
extractor: { model: 'google/gemini-2.5-flash', apiKey: '...' },
});
// Available tools:
// - scrape-url: Single URL scraping
// - scrape-batch: Multiple URLs in parallel
// - extract-schema: Schema-based extraction
// - clear-cache: Clear all caches
// - get-stats: Get statistics
// Call from external MCP client
const result = await server.callTool({
name: 'scrape-url',
arguments: {
url: 'https://example.com',
task: 'Extract all links',
}
});Run the examples:
# Basic scraping
npm run example:basic
# Multi-agent workflow
npm run example:multi
# MCP client
npm run example:mcpconst result = await orchestrator.scrape({
task: 'Extract product name, price, availability, and ratings',
url: 'https://amazon.com/dp/B08N5KWB9H',
schema: {
type: 'object',
properties: {
name: { type: 'string' },
price: { type: 'number' },
currency: { type: 'string' },
availability: { type: 'string' },
rating: { type: 'number' },
reviews: { type: 'integer' }
}
}
});const result = await orchestrator.scrape({
task: `
1. Search for "software engineer" jobs
2. Filter by location "Remote"
3. Extract job title, company, salary, and application URL
`,
url: 'https://linkedin.com/jobs',
schema: {
type: 'array',
items: {
type: 'object',
properties: {
title: { type: 'string' },
company: { type: 'string' },
salary: { type: 'string' },
location: { type: 'string' },
applyUrl: { type: 'string' }
}
}
}
});const urls = [
'https://techcrunch.com',
'https://theverge.com',
'https://arstechnica.com',
];
const results = await orchestrator.scrapeBatch(
urls.map(url => ({
task: 'Extract article title, author, publish date, and summary',
url,
schema: {
type: 'array',
items: {
type: 'object',
properties: {
title: { type: 'string' },
author: { type: 'string' },
date: { type: 'string' },
summary: { type: 'string' },
url: { type: 'string' }
}
}
}
})),
3
);Single-agent wrapper around page-agent.
Methods:
initialize(): Initialize the agent (must be called first)navigate(url): Navigate to a URLexecute(task): Execute a natural language taskextractData(schema): Extract structured data using schemaclearCache(): Clear cached results
Multi-agent orchestration.
Methods:
initialize(): Initialize all agentsscrape(taskConfig): Execute scraping with multi-agent workflowscrapeBatch(tasks, concurrency): Execute multiple scraping tasks in parallelclearCache(): Clear all caches
MCP server for external control.
Tools:
scrape-url: Single URL scrapingscrape-batch: Batch scrapingextract-schema: Schema-based extractionclear-cache: Clear cacheget-stats: Get statistics
# Build
npm run build
# Run examples
npm run example:basic
npm run example:multi
npm run example:mcp
# Test
npm testbrowser-scraper/
βββ src/
β βββ agents/
β β βββ orchestrator.ts # Multi-agent coordinator
β βββ page-agent/
β β βββ wrapper.ts # Page-agent integration
β βββ storage/
β β βββ cache.ts # Caching layer
β βββ mcp/
β β βββ server.ts # MCP server
β βββ index.ts # Main entry
βββ examples/
β βββ basic.ts # Basic example
β βββ multi-agent.ts # Multi-agent workflow
β βββ mcp-client.ts # MCP client
βββ tests/
βββ package.json
βββ tsconfig.json
βββ README.md
- Respect robots.txt: Always check website's robots.txt
- Rate limiting: Use caching and respect rate limits
- Terms of Service: Ensure scraping is allowed by ToS
- Data usage: Use scraped data responsibly and legally
Contributions welcome! Please read CONTRIBUTING.md first.
MIT License - see LICENSE file for details.
- page-agent - DOM-based browser automation
- OpenRouter - Multi-model LLM API
- Hermes Agent - Multi-agent framework
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with β€οΈ using page-agent and Hermes Agent