如何从 IMDB 获取电影或电视节目的年份

How to get year of a movie or TV Show from IMDB

有人能告诉我如何从 php 中的 IMDB 获取一年的特定电影或电视节目吗?

OMDB ABI 在这种情况下可能会有所帮助。您需要做的就是发送一个 HTTP 请求(包括对服务的电影标题)。假设匹配,您将得到一个 JSON-formatted 字符串,其中包含相关年份的电影。

例如:

要求:

http://www.omdbapi.com/?t=Batman&y=&plot=short&r=json

回复:

{"Title":"Batman","Year":"1989","Rated":"PG-13","Released":"23 Jun 1989","Runtime":"126 min","Genre":"Action, Adventure","Director":"Tim Burton","Writer":"Bob Kane (Batman characters), Sam Hamm (story), Sam Hamm (screenplay), Warren Skaaren (screenplay)","Actors":"Michael Keaton, Jack Nicholson, Kim Basinger, Robert Wuhl","Plot":"The Dark Knight of Gotham City begins his war on crime with his first major enemy being the clownishly homicidal Joker.","Language":"English, French","Country":"USA, UK","Awards":"Won 1 Oscar. Another 9 wins & 21 nominations.","Poster":"http://ia.media-imdb.com/images/M/MV5BMTYwNjAyODIyMF5BMl5BanBnXkFtZTYwNDMwMDk2._V1_SX300.jpg","Metascore":"66","imdbRating":"7.6","imdbVotes":"235,641","imdbID":"tt0096895","Type":"movie","Response":"True"}

您可以使用 CURL 获取此数据:

$service_url = 'http://www.omdbapi.com/';
   $curl = curl_init($service_url);
   $curl_post_data = array(
        "t" => 'batman',
        );
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($curl, CURLOPT_POST, true);
   curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
   $curl_response = curl_exec($curl);
   curl_close($curl);

或者,如果您不介意切换语言,还有一个名为 imdbpy.

的 Python IMDB 搜索包

根据我的经验,如果您需要进行一些快速查询并且始终可以访问 Internet,则 OMDB 非常有用。

另一方面,IMDBPY 允许您创建 IMDB 数据集的本地版本(在 XML 中或作为 SQL 数据库)。这个比较适合做大的操作(比如创建本地电影搜索平台)。