Extract Open Graph and Twitter Card images from any website. Uses Firecrawl to efficiently map and scrape sites.
- Maps entire websites to discover all URLs
- Extracts OG images (
og:image) and Twitter images (twitter:image) - Downloads images locally
- Generates reports in multiple formats:
- Markdown - Easy to read, great for documentation
- HTML - Visual gallery with image previews
- JSON - Raw data for further processing
# Clone the repo
git clone https://github.com/yourusername/OG-scraper.git
cd OG-scraper
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env and add your Firecrawl API key- Go to firecrawl.dev
- Sign up for an account
- Get your API key from the dashboard
- Add it to your
.envfile
# Basic usage - scrape a website
FIRECRAWL_API_KEY=your_key npx tsx scrape-social-images.ts https://example.com
# Or if you have .env set up
npx tsx scrape-social-images.ts https://example.com
# Filter URLs by search term (only scrape pages matching "blog")
npx tsx scrape-social-images.ts https://example.com blogResults are saved to the output/ directory:
output/
├── social-images.md # Markdown report
├── social-images.html # Visual HTML gallery (open in browser)
├── social-images.json # Raw JSON data
└── images/ # Downloaded images
├── page-slug_og.jpg
└── page-slug_twitter.jpg
Markdown Report:
# Social Image Report
**Site:** https://example.com
**Pages with images:** 15
---
## Page Title
**URL:** https://example.com/page
### OG Image
HTML Gallery:
Open output/social-images.html in your browser for a visual grid of all discovered social images.
You can modify these options in the script:
| Option | Default | Description |
|---|---|---|
outputDir |
./output |
Where to save results |
downloadImages |
true |
Download images locally |
limit |
50 |
Max URLs to map |
concurrency |
5 |
Parallel scrape requests |
- Map - Uses Firecrawl's
/mapendpoint to quickly discover all URLs on the site - Scrape - Fetches metadata from each page in parallel batches
- Extract - Pulls
og:imageandtwitter:imagefrom metadata - Download - Saves images locally with slugified filenames
- Report - Generates Markdown, HTML, and JSON reports
- External subdomains may fail to scrape (e.g.,
docs.example.comwhen scrapingexample.com) - PDFs and other non-HTML resources are skipped
- Rate limiting may cause some pages to fail on large sites
- Pages without OG/Twitter images configured won't appear in results
MIT