Metadata-Version: 2.4
Name: how-to-scrape-imdb-data
Version: 0.0.1
Summary: Python client for scraping IMDb title data using the ScrapingBee web scraping API
Author: wordstotech
License: MIT
Project-URL: Homepage, https://www.scrapingbee.com/blog/how-to-scrape-imdb/
Keywords: how to scrape imdb data,imdb scraper,how to scrape imdb,imdb data,scrapingbee
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Dynamic: license-file

# how-to-scrape-imdb-data

Scrape IMDb title data into parsed JSON. A thin Python wrapper over the ScrapingBee web scraping API that fetches an IMDb page through residential proxies and returns fields using the extraction rules from ScrapingBee's IMDb guide.

```bash
pip install how-to-scrape-imdb-data
```

If you searched for how to scrape IMDb data, or you need a reliable IMDb scraper that does not get blocked, this is the wrapper. Requires Python 3.8+ and `requests`.

## 30-second example

```python
from how_to_scrape_imdb_data import ImdbScraper

scraper = ImdbScraper(api_key="YOUR_API_KEY")

movie = scraper.title("tt1375666")  # Inception
print(movie)
```

Grab a key first. ScrapingBee gives 1,000 credits with no card at [scrapingbee.com](https://www.scrapingbee.com/).

## The client

```python
ImdbScraper(api_key: str, timeout: int = 60)
```

Requests use a premium (residential) proxy by default, which is what keeps IMDb from blocking a repeated job. The client serializes extraction rules and builds title URLs for you.

## Methods

### `title(title_id, extract_rules=None, **kwargs)`

Scrape an IMDb title page by its id, for example `tt1375666`. Returns JSON with `title`, `rating`, `genres`, `summary`, and `director` by default.

| Argument | Purpose |
|---|---|
| `title_id` | IMDb id such as `tt1375666` (required) |
| `extract_rules` | Override the default fields with your own selectors |
| `premium_proxy` | Residential proxies (default `True`) |
| `render_js` | Force or disable JavaScript rendering (default: platform default) |
| `extra` | Dict of any other documented HTML API parameter |

### `scrape(url, extract_rules=None, **kwargs)`

Fetch any IMDb URL, such as a person page or a chart. Returns rendered HTML by default, or JSON when you pass `extract_rules`.

## Default fields

The default extraction uses the selectors from ScrapingBee's IMDb guide:

```python
{
    "title": {"selector": "h1", "type": "text"},
    "rating": {"selector": "span[role='img']", "type": "text"},
    "genres": {"selector": "div[data-testid='genres'] a", "type": "list"},
    "summary": {"selector": "span[data-testid='plot-xl']", "type": "text"},
    "director": {"selector": "li[data-testid='title-pc-principal-credit']:first-child a", "type": "text"},
}
```

Pass your own `extract_rules` when you need different fields, or add `ai_extract_rules` through `extra` for natural-language extraction.

## Scrape a list of movies

```python
scraper = ImdbScraper(api_key="YOUR_API_KEY")

ids = ["tt0111161", "tt0068646", "tt1375666"]
catalog = [scraper.title(tid) for tid in ids]
```

## 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. See [scrapingbee.com/pricing](https://www.scrapingbee.com/pricing/).

## Notes

- Scrape public IMDb pages only. ScrapingBee's terms prohibit scraping behind a login.
- Selectors reflect IMDb's current title-page markup and may need updating over time.

## Links

- [How to scrape IMDb (ScrapingBee)](https://www.scrapingbee.com/blog/how-to-scrape-imdb/)
- [Data extraction rules](https://www.scrapingbee.com/documentation/data-extraction/)
- [ScrapingBee pricing](https://www.scrapingbee.com/pricing/)

## License

MIT

## Disclaimer

Unofficial Python client built on the ScrapingBee web scraping API. Not affiliated with ScrapingBee or IMDb. Comply with IMDb's terms of service and applicable law.
