Is any one tell me how to get a year of specific movie or TV show from IMDB in php?
1条回答 默认 最新
- doq1969 2015-04-22 15:59关注
The OMDB ABI might be of help in this instance. All you would need to do is send an HTTP request (including the a movie's title to the service). Assuming a match, you will get back a JSON-formatted string containing the movie in question's year.
For example:
Request:
Response:
{"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"}
You could use CURL to get this data:
$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);
Alternatively, if you don't mind switching languages, there is also a Python IMDB search package called imdbpy.
In my experience, OMDB is great if you need to make a few quick queries and will always have access to the Internet.
On the other hand, IMDBPY allows you to create a local version of the IMDB data set (in XML or as a SQL DB). This is more suitable for large operations (such as creating a local movie search platform).
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
- ¥30 eclipse开启服务后,网页无法打开
- ¥30 雷达辐射源信号参考模型
- ¥15 html+css+js如何实现这样子的效果?
- ¥15 STM32单片机自主设计
- ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
- ¥15 不小心不正规的开发公司导致不给我们y码,
- ¥15 我的代码无法在vc++中运行呀,错误很多
- ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
- ¥60 fail to initialize keyboard hotkeys through kernel.0000000000