Installation
npm install web-meta-scraperRequirements
- Node.js 18 or later (for native
fetch()support) - TypeScript 5.0+ (optional, but recommended)
Module Formats
web-meta-scraper ships with both CommonJS and ESM builds:
// ESM
import { scrape, createScraper } from 'web-meta-scraper';
// CommonJS
const { scrape, createScraper } = require('web-meta-scraper');Exports
| Export | Description |
|---|---|
scrape | Convenience function — auto-detects URL vs HTML, uses all built-in plugins |
createScraper | Factory function for full control over plugins, rules, and options |
ScraperError | Custom error class thrown on failures |
metaTags | Plugin for standard HTML meta tags |
openGraph | Plugin for Open Graph protocol |
twitter | Plugin for Twitter Cards |
jsonLd | Plugin for JSON-LD structured data |
oembed | Plugin for oEmbed discovery |
DEFAULT_RULES | Default priority resolve rules |
createContext | Helper to create a ScrapeContext for testing plugins |
fetchHtml | Standalone HTML fetcher function |
Type Exports
| Type | Description |
|---|---|
ScraperConfig | Configuration for createScraper() |
ScraperResult | Return type with metadata and sources |
ResolvedMetadata | Merged metadata output type |
Plugin | Plugin function type |
PluginResult | Plugin return type |
ScrapeContext | Context passed to plugins |
ResolveRule | Priority resolve rule type |
FetchOptions | Options for fetchHtml |
ScraperOptions | General scraper options |
JsonLdMetadata | JSON-LD data type |
OEmbedData | oEmbed data type |