-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Welcome to the imdb-scraper wiki!
This library scrapes imdb.com so changes their site can cause parts of this library to fail. You will probably need to update a few times a year.
- PHP >= 8.0
- PHP cURL extension
- PHP json extension
$ composer require hooshid/imdb-scraperThe example gives you a quick demo to make sure everything's working, some sample code and lets you easily see some available data.
From the example folder in the root of this repository start up php's inbuilt webserver and browse to http://localhost:8000
php -S localhost:8000
this package needs no configuration by default but can change languages of imdb.com if you want.
Configuration is done by the \Hooshid\ImdbScraper\Base\Config class.
You can alter the config by creating the object, modifying its properties then passing it to the constructor for imdb.
$config = new \Hooshid\ImdbScraper\Base\Config();
$config->language = 'de-DE';
$title = new \Hooshid\ImdbScraper\Title(335266, $config);
echo $title->title(); // Lost in Translation - Zwischen den Welten
echo $title->originalTitle(); // Lost in TranslationMovie: The Matrix (1999) / URL: https://www.imdb.com/title/tt0133093 / ID: 0133093
$config = new \Hooshid\ImdbScraper\Base\Config();
$config->language = 'en-US,en';
$title = new \Hooshid\ImdbScraper\Title(0133093, $config);
echo $title->title(); // The Matrix
echo $title->year(); // 1999
// get all available data as json
echo json_encode($title->full());Tv Series: Game of Thrones (2011-2019) / URL: https://www.imdb.com/title/tt0944947 / ID: 0944947
$title = new \Hooshid\ImdbScraper\Title(0944947); // without config!
echo $title->title(); // Game of Thrones
echo $title->year(); // 2011
echo $title->endYear(); // 2019 -> just for series
echo $title->genres(); // Array of genres: ["Action", "Adventure", "Drama"]
echo $title->languages(); // Array of languages: ["English"]
echo $title->countries(); // Array of countries: ["United States", "United Kingdom"]
echo $title->rating(); // 9.2
echo $title->votes(); // 2022832
// get all available data as json
echo json_encode($title->full());Person: Christopher Nolan / URL: https://www.imdb.com/name/nm0634240 / ID: 0634240
$person = new \Hooshid\ImdbScraper\Name(0634240); // without config!
echo $person->fullName(); // Christopher Nolan
echo $person->birthName(); // Christopher Edward Nolan
echo $person->birth()["date"]; // 1970-07-30
echo $person->birth()["place"]; // London, England, UK
// get all available data as json
echo json_encode($person->full());just open the example folder, we put all examples and methods demo for you in there!
Hooshid\ImdbScraper stands out from other packages by focusing on modern PHP practices and developer experience. Below is a list of key features and benefits that make it a superior choice:
- Modern PHP 8+ Compatibility: Built exclusively for PHP 8 and later, leveraging the latest language features like strong typing, union types, and improved performance.
- Strongly Typed Codebase: Every class, method, and parameter is strongly typed, ensuring type safety, reducing runtime errors, and improving code clarity for developers.
- Exception-Based Error Handling: Returns meaningful exceptions for robust and predictable error handling, making debugging easier and more reliable compared to alternatives.
- No Global Configuration: Say goodbye to rigid global configs! Hooshid\ImdbScraper allows flexible, per-method parameter passing, giving you full control without hidden state dependencies.
- Lightweight and Focused: No unnecessary bloat like built-in loggers, caching, or image downloaders. This keeps the package lean, fast, and focused on its core functionality.
- Consistent Data Output: Returns values exactly as they appear in the source (e.g., IMDb IDs like tt123456 remain unchanged), ensuring data integrity and consistency with external APIs.
- Comprehensive Documentation: Every class and method is thoroughly documented, making it easy to understand and integrate the package into your projects.
- Interactive Example UI: Includes a beautifully designed, user-friendly interface to test and explore the package’s features with real-world examples, helping you get started quickly.
- Composer Compatibility: Seamlessly integrates with Composer for easy installation and dependency management, fitting perfectly into modern PHP workflows.
- Well-Tested Codebase: Rigorously tested methods ensure reliability and stability, giving you confidence in production environments.
Unlike other packages that rely on outdated PHP versions or include unnecessary features like loggers, caches, or image downloaders, Hooshid\ImdbScraper focuses on delivering a clean, modern, and efficient solution. By avoiding global configurations and embracing per-method parameters, it offers greater flexibility and transparency. The strongly typed codebase and exception-based error handling make it a joy to work with, while the comprehensive documentation and interactive UI lower the learning curve.