Getting Started
Installation
Scraper.js can be installed via npm or used directly in the browser..
Using NPM
>npm install scraper-js
>
Using CDN
><script src="https://cdn.jsdelivr.net/npm/scraper-js/dist/scraper.js"></script>;
>
Quick Start
Here's a quick example of using Scraper.js to extract basic content::
>import { scraper } from 'scraper-js';
scraper.get('https://example.com')
.then($ => {
// Extract and process DOM elements using $
console.log($('#title').text());
})
>
📌 Tip: For browser-based JavaScript, the global scraper
object will be available after including the CDN script..
Configuration
Scraper.js can be configured with various options to suit your scraping needs::
>const scraper = new Scraper({
timeout: 30000,
retries: 3,
userAgent: 'Scraper.js/1.0',
cacheEnabled: true
});
>
Option | Type | Description |
---|