我最近发现了一个从IMDB数据库获取数据的电影管理应用程序。
IMDB是否为此提供API,或任何可用的第三方API ?
我最近发现了一个从IMDB数据库获取数据的电影管理应用程序。
IMDB是否为此提供API,或任何可用的第三方API ?
当前回答
https://deanclatworthy.com/tools.html是一个IMDB API,但由于滥用已经关闭。
其他回答
新火@ http://www.omdbapi.com
编辑:由于法律问题不得不将服务转移到一个新的域名:)
最近在SXSWi 2012上,在他们的“Mashery Lounge”中,有一个来自rovi的类似imdb的API的展位。这不是一个免费的API,但据我采访的销售人员说,他们根据你的预算提供收益分成或固定费用。我还没用过,不过看起来挺酷的。
IMDb有一个公共API,虽然没有文档记载,但是快速可靠(在官方网站上通过AJAX使用)。
搜索建议API
https://sg.media-imdb.com/suggests/h/hello.json https://v2.sg.media-imdb.com/suggests/h/hello.json (as of 2019) Format: JSON-P Caveat: It's in JSON-P format, and the callback parameter can not customised. To use it cross-domain you'll have to use their function name for the callback (which is in the imdb${searchphrase} format). Alternatively, one could strip or replace the padding via a local proxy. https://v2.sg.media-imdb.com/suggestion/h/hello.json (as of 2020) Format: JSON Caveat: It's not CORS-enabled. This is fine for use in apps and server-side scripts. For use in a web app, you'll need to route it through a simple proxy (and consider enabling caching, too!)
// 1) Vanilla JavaScript (JSON-P)
function addScript(src) { var s = document.createElement('script'); s.src = src; document.head.appendChild(s); }
window.imdb$foo = function (results) {
/* ... */
};
addScript('https://sg.media-imdb.com/suggests/f/foo.json');
// 2) Using jQuery (JSON-P)
jQuery.ajax({
url: 'https://sg.media-imdb.com/suggests/f/foo.json',
dataType: 'jsonp',
cache: true,
jsonp: false,
jsonpCallback: 'imdb$foo'
}).then(function (results) {
/* ... */
});
// 3) Pure JSON (with jQuery)
// Use a local proxy to the clean `/suggestion` API.
jQuery.getJSON('/api/imdb/?q=foo', function (results) {
/* ... */
});
// 4) Pure JSON (plain JavaScript; Modern ES6, ES2017, and Fetch API)
// Serve a "/api" route in your app, that proxies (and caches!)
// to v2.sg.media-imdb.com/suggestion/h/hello.json
const resp = await fetch('/api/imdb/?q=foo');
const results = await resp.json();
高级搜索
名称搜索(json): http://www.imdb.com/xml/find?json=1&nr=1&nm=on&q=jeniffer+garner 标题搜索(xml): http://www.imdb.com/xml/find?xml=1&nr=1&tt=on&q=lost 格式:XML 优点:同时支持电影名称和演员名称(与建议API不同)。
请注意,这些api是非官方的,随时都可能更改!
更新(2019年1月):高级API不再存在。好消息是,建议API现在支持“高级”功能,即通过电影名称和演员名称进行搜索。
下面是一个简单的解决方案,根据Krinkle的查询按名称获取节目:
您可以通过让服务器获取URL来绕过同源策略,而不是试图直接使用AJAX获取URL,并且不必使用JSONP来完成此操作。
Javascript (jQuery):
function getShowOptionsFromName (name) {
$.ajax({
url: "ajax.php",
method: "GET",
data: {q: name},
dataType: "json"
}).done(function(data){
console.log(data);
});
}
PHP(在ajax.php文件):
$q = urlencode($_GET["q"]);
echo file_get_contents("http://www.imdb.com/xml/find?json=1&nr=1&tt=on&q=$q");
https://deanclatworthy.com/tools.html是一个IMDB API,但由于滥用已经关闭。