1. Go to this page and download the library: Download mfonte/imdb-scraper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mfonte / imdb-scraper example snippets
use Mfonte\ImdbScraper\Imdb;
use Mfonte\ImdbScraper\Exceptions\NoSearchResults;
use Mfonte\ImdbScraper\Exceptions\MultipleSearchResults;
// Create an IMDb scraper instance
$imdb = Imdb::new(['locale' => 'en']);
// Fetch movie details using best match
$movie = $imdb->movie('The Godfather');
// Output some details
echo $movie->title; // The Godfather
echo $movie->year; // 1972
echo $movie->plot; // "The aging patriarch of an organized crime dynasty transfers control..."
// When using movie(), tvSeries(), movieByYear(), or tvSeriesByYear(), catch exceptions!
try {
$movie = $imdb->movie('The Godfather');
} catch (NoSearchResults $e) {
echo 'No results found!';
} catch (MultipleSearchResults $e) {
echo 'Multiple results found!';
}
// you can also fetch a Title by its IMDB ID
$item = $imdb->id('tt0068646');
echo $item->title; // The Godfather
// you can also only search for results
$results = $imdb->search('godfather');
use Mfonte\ImdbScraper\Imdb;
// Enable caching and use Italian locale
$imdb = Imdb::new([
'cache' => true,
'locale' => 'it'
]);
// Fetch a localized movie
$movie = $imdb->movie('La ricerca della felicità');
echo $movie->title; // La ricerca della felicità
use Mfonte\ImdbScraper\Imdb;
// Fetch the best match for a movie title
$movie = Imdb::new()->movie('godfather');
echo $movie->id; // tt0068646
echo $movie->title; // The Godfather
echo $movie->year; // 1972
use Mfonte\ImdbScraper\Imdb;
// Fetch a movie by title and year
$movie = Imdb::new()->movieByYear('from dusk dawn', 1996);
echo $movie->id; // tt0116367
echo $movie->title; // From Dusk Till Dawn
echo $movie->year; // 1996
use Mfonte\ImdbScraper\Imdb;
use Mfonte\ImdbScraper\Exceptions\NoSearchResults;
$imdb = Imdb::new(['locale' => 'en']);
try {
$movie = $imdb->movie('nonexistent title');
} catch (NoSearchResults $e) {
echo 'No results found for the query.';
}
use Mfonte\ImdbScraper\Imdb;
use Mfonte\ImdbScraper\Exceptions\MultipleSearchResults;
$imdb = Imdb::new(['locale' => 'en']);
try {
$movie = $imdb->movie('godfather');
} catch (MultipleSearchResults $e) {
echo 'Multiple results found for the query.';
}
use Mfonte\ImdbScraper\Imdb;
use Mfonte\ImdbScraper\Exceptions\BadMethodCall;
$imdb = Imdb::new(['locale' => 'en']);
try {
$movie = $imdb->id('invalid_id');
} catch (BadMethodCall $e) {
echo 'Invalid IMDb ID provided.';
}