我最近发现了一个电影组织者应用程序,它从互联网电影数据库 http://www.imdb.com.
Does IMDB http://www.imdb.com为此提供 API,或任何可用的第三方 API?
IMDb 有一个公共 API,虽然没有文档记录,但快速可靠(通过 AJAX 在官方网站上使用)。
搜索建议 API
-
https://sg.media-imdb.com/suggests/h/hello.json https://sg.media-imdb.com/suggests/h/hello.json
-
https://v2.sg.media-imdb.com/suggests/h/hello.json https://v2.sg.media-imdb.com/suggests/h/hello.json(截至2019年)
- 格式:JSON-P
- 注意:它是JSON-P格式,并且回调参数不能自定义。要跨域使用它,您必须使用它们的回调函数名称(位于
imdb${searchphrase}
格式)。或者,可以通过本地代理去除或替换填充。
-
https://v2.sg.media-imdb.com/suggestion/h/hello.json https://v2.sg.media-imdb.com/suggestion/h/hello.json(截至2020年)
- 格式:JSON
- 警告:它不支持 CORS。这非常适合在应用程序和服务器端脚本中使用。为了在网络应用程序中使用,您需要通过一个简单的代理来路由它(并考虑启用缓存!)
// 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();
高级搜索
Name search (json):
- 标题搜索(xml):
- 格式:XML
- 优点:支持电影标题和演员姓名(与建议 API 不同)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)