how-to-scrape-imdb-data
v0.0.2
Published
Node.js client for scraping IMDb title data using the ScrapingBee web scraping API.
Downloads
289
Maintainers
Readme
how-to-scrape-imdb-data
Node.js client for scraping IMDb title data through the ScrapingBee web scraping API. Pull a movie's title, rating, genres, summary, and director as JSON, with residential proxies and extraction handled server-side. If you want to know how to scrape IMDb without getting blocked, this is the wrapper.
npm install how-to-scrape-imdb-dataFree tier: 1,000 credits, no card, at scrapingbee.com.
Scrape a movie in a few lines
Every IMDb movie has a tt id, the code in its URL. Pass that id and this IMDb scraper returns the structured fields.
const { ImdbScraper } = require('how-to-scrape-imdb-data');
const scraper = new ImdbScraper({ apiKey: 'YOUR-API-KEY' });
async function run() {
const movie = await scraper.title('tt1375666'); // Inception
console.log(movie.title, movie.rating, movie.genres);
}
run();Every method returns a Promise. The premium proxy is on by default, which is what keeps a repeated job from getting blocked.
Build a small catalog
const ids = ['tt0111161', 'tt0068646', 'tt1375666'];
const catalog = [];
for (const id of ids) {
catalog.push(await scraper.title(id));
}Custom fields or any IMDb page
// change which fields you extract
const data = await scraper.title('tt1375666', {
extractRules: {
title: { selector: 'h1', type: 'text' },
year: { selector: "a[href*='releaseinfo']", type: 'text' },
},
});
// or scrape any IMDb URL and get raw HTML back
const html = await scraper.scrape('https://www.imdb.com/chart/top/');API reference
new ImdbScraper({ apiKey, timeout })
| Option | Type | Default | Description |
| --- | --- | --- | --- |
| apiKey | string | required | Your ScrapingBee API key |
| timeout | number | 60000 | Request timeout in milliseconds |
.title(titleId, options)
Scrape an IMDb title page by id. Returns JSON with the default fields (title, rating, genres, summary, director) unless you override extractRules.
| Option | API parameter | Default | Description |
| --- | --- | --- | --- |
| extractRules | extract_rules | default fields | Your own CSS selectors |
| premiumProxy | premium_proxy | true | Residential proxies |
| renderJs | render_js | platform default | Force or disable JavaScript rendering |
| extra | (any) | {} | Any other documented HTML API parameter |
.scrape(url, options)
Fetch any IMDb URL. Returns rendered HTML, or JSON when extractRules is passed.
What a title call returns
Using the default selectors from ScrapingBee's IMDb guide:
{
"title": "Inception",
"rating": "8.8/10",
"genres": ["Action", "Adventure", "Sci-Fi"],
"summary": "A thief who steals corporate secrets...",
"director": "Christopher Nolan"
}Credits
ScrapingBee bills successful requests. An IMDb title request with a premium proxy and the default rendering costs 25 credits. CSS extraction adds nothing; ai_extract_rules adds 5. Current pricing: scrapingbee.com/pricing.
FAQ
How do I scrape IMDb data at scale?
Route requests through rotating residential proxies. This wrapper does that by default, so you can loop over many tt ids without IMDb blocking you.
Where do the default fields come from?
The default selectors match ScrapingBee's IMDb guide. Override them with extractRules when you need different fields.
Can I scrape charts like the Top 250?
Yes. Call scrape('https://www.imdb.com/chart/top/') for the HTML, or pass extractRules to get structured JSON.
Is scraping IMDb allowed?
Public data is generally collectible for research and analysis, but IMDb's terms and local rules apply. Scrape public pages only.
Links
License
MIT. See LICENSE.
Disclaimer
Unofficial Node.js wrapper around the ScrapingBee web scraping API. Not affiliated with ScrapingBee or IMDb. Compliance with IMDb's terms of service and applicable law is the responsibility of the operator.
