hooshid/imdb-scraper

从imdb.com检索电影、电视剧信息的库

2.2.0 2024-08-06 06:27 UTC

This package is auto-updated.

Last update: 2024-09-25 07:10:40 UTC


README

Build Status Total Downloads Latest Stable Version License

使用此IMDb API,您可以在imdb.com上搜索、浏览和提取电影、电视剧和音乐的数据。

安装

此库抓取imdb.com,因此网站更改可能会使此库的部分功能失效。您可能需要每年更新几次。

要求

  • PHP >= 7.3
  • PHP cURL扩展

通过composer安装

$ composer require hooshid/imdb-scraper

运行示例

示例提供了一个快速演示,以确保一切正常,一些示例代码,并让您轻松地看到一些可用数据。

从此存储库根目录中的示例文件夹启动PHP的内置Web服务器,并浏览到https://:8000

php -S localhost:8000

示例

设置配置

此包默认不需要配置,但您可以根据需要更改imdb.com的语言。

配置是通过\Hooshid\ImdbScraper\Base\Config类完成的。您可以通过创建对象,修改其属性,然后将它传递给IMDb的构造函数来更改配置。

$config = new \Hooshid\ImdbScraper\Base\Config();
$config->language = 'de-DE,de,en';
$title = new \Hooshid\ImdbScraper\Title(335266, $config);
echo $title->title(); // Lost in Translation - Zwischen den Welten
echo $title->originalTitle(); // Lost in Translation

获取电影/电视剧(标题)数据

电影:The Matrix (1999) / 网址: 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());

电视剧:Game of Thrones (2011-2019) / 网址: 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());

获取名称数据

人物:Christopher Nolan / 网址: 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());

其他示例

只需打开示例文件夹,我们在其中为您提供了所有示例和方法演示!

相关项目

支持页面

  • 搜索
    • 标题(电影、电视剧、集数等)
    • 名称(演员、导演等)
  • 图表
    • Top 250 电影
    • Top 250 电视剧
    • 票房
  • 名称
    • 全名 & 出生名 & 昵称
    • 照片
    • 出生日期 & 出生地点
    • 死亡日期 & 死亡地点 & 死因
    • 简介
    • 身高
  • 标题
    • 电影/电视剧标题
    • 预告片
    • 剧集季节

许可证

MIT许可证(MIT)。请参阅许可证文件获取更多信息。