问题描述
我最近发现它从获取其数据的影片管理器应用程序。
提供此提供一个API,或任何第三方的API?
在IMDB目前有那些,虽然无证,非常快速和可靠的(通过AJAX自己的网站上使用)两个公共的API。
-
一个静态缓存搜索建议API:
- 格式:JSONP
-
缺点:
-
这是JSONP格式,但是回调参数不能传递一个回调查询参数进行设置。为了使用它跨域你将不得不使用他们选择的函数名(这是在IMDB $ {} searchphrase的格式,见下面的例子)。或者使用一个本地代理(例如一个小的PHP文件),从IMDB下载(和缓存!),并剥离JSON-P的回调,或自定义的回调来替换它。
-
如果没有结果,这不正常回落,但显示XML错误,而不是
-
//基本
window.imdb $ = foo的功能(名单){
/ * ... * /
};
jQuery.getScript('http://sg.media-imdb.com/suggests/f/foo.json');//使用jQuery.ajax(jQuery的让处理回调)
jQuery.ajax({
网址:'http://sg.media-imdb.com/suggests/f/foo.json',
数据类型:'JSONP',
缓存:真实,
JSONP:假的,
jsonpCallback:IMDB $富'
})。完成(功能(结果){
/ * ... * /
});//在当地代理与消毒PHP脚本替换IMDB $ foo的
//的$ _GET版['回调'](http://stackoverflow.com/a/8811412/319266)
jQuery.getJSON('./ imdb.php Q =富&放大器;回调=?,功能(名单){
/ * ... * /
});
更高级的搜索
- 名称搜索(JSON):<一href=\"http://www.imdb.com/xml/find?json=1&nr=1&nm=on&q=jeniffer+garner\">http://www.imdb.com/xml/find?json=1&nr=1&nm=on&q=jeniffer+garner
- 标题搜索(XML):<一href=\"http://www.imdb.com/xml/find?xml=1&nr=1&tt=on&q=lost\">http://www.imdb.com/xml/find?xml=1&nr=1&tt=on&q=lost
- 格式:JSON,XML等
- 缺点:
- 无JSONP。为了从JavaScript跨域使用,需要一个本地代理。
- 没有文件,更多的格式可能是可用
- 上扬
- Live搜索的!
- 对演员名称的支持,以及!
- 适当回落到空对象
至于说,这两个API被无证。他们可以在任何时候改变。
另请参阅,对于一个JSON API的例子在PHP。
I recently found a movie organizer application which fetches its data from the IMDB database.
Does IMDB provide an API for this, or any third party APIs available?
The IMDb currently has two public APIs that are, although undocumented, very quick and reliable (used on their own site through AJAX).
A statically cached search suggestions API:
- http://sg.media-imdb.com/suggests/a/aa.json
- http://sg.media-imdb.com/suggests/h/hello.json
- Format: JSONP
Downside:
It's in JSONP format, however the callback parameter can not be set by passing a callback-query parameter. In order to use it cross-domain you'll have to use the function name they choose (which is in the "imdb${searchphrase}" format, see example below). Or use a local proxy (e.g. a small php file) that downloads (and caches!) it from IMDb and strips the JSON-P callback, or replaces it with a custom callback.
If there are no results, it doesn't gracefully fallback, but displays an XML error instead
// Basic
window.imdb$foo = function (list) {
/* ... */
};
jQuery.getScript('http://sg.media-imdb.com/suggests/f/foo.json');
// Using jQuery.ajax (let jQuery handle the callback)
jQuery.ajax({
url: 'http://sg.media-imdb.com/suggests/f/foo.json',
dataType: 'jsonp',
cache: true,
jsonp: false,
jsonpCallback: 'imdb$foo'
}).done(function (result) {
/* ... */
});
// With local proxy to a PHP script replacing imdb$foo with a sanitized
// version of $_GET['callback'] (http://stackoverflow.com/a/8811412/319266)
jQuery.getJSON('./imdb.php?q=foo&callback=?', function (list) {
/* ... */
});
More advanced search
- Name search (json): http://www.imdb.com/xml/find?json=1&nr=1&nm=on&q=jeniffer+garner
- Title search (xml): http://www.imdb.com/xml/find?xml=1&nr=1&tt=on&q=lost
- Format: JSON, XML and more
- Downside:
- No JSONP. In order to use from JavaScript cross-domain, a local proxy is required.
- No documentation, more formats may be available
- Upside
- Live search!
- Name support for actors as well!
- Proper fallback to empty object
As said, both of these APIs are undocumented. They could change at any time.
See also http://stackoverflow.com/a/8811412/319266, for an example of a JSON API in PHP.
这篇关于IMDB是否提供API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!