我最近发现了一个从IMDB数据库获取数据的电影管理应用程序。
IMDB是否为此提供API,或任何可用的第三方API ?
我最近发现了一个从IMDB数据库获取数据的电影管理应用程序。
IMDB是否为此提供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");
其他回答
找到了这个
IMDbPY是一个用于检索和管理数据的Python包 IMDb的电影数据库,关于电影,人物,人物和 公司。
http://imdbpy.sourceforge.net/
好吧,我找到了这一个IMDB刮刀
c#: http://web3o.blogspot.de/2010/11/aspnetc-imdb-scraping-api.html
PHP: http://web3o.blogspot.de/2010/10/php-imdb-scraper-for-new-imdb-template.html
或者c#的imdbapi.org实现:
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Xml.Linq;
using HtmlAgilityPack; // http://htmlagilitypack.codeplex.com/
public class IMDBHelper
{
public static imdbitem GetInfoByTitle(string Title)
{
string url = "http://imdbapi.org/?type=xml&limit=1&title=" + Title;
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
req.Method = "GET";
req.UserAgent = "Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))";
string source;
using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream()))
{
source = reader.ReadToEnd();
}
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(source);
XDocument xdoc = XDocument.Parse(doc.DocumentNode.InnerHtml, LoadOptions.None);
imdbitem i = new imdbitem();
i.rating = xdoc.Descendants("rating").Select(x => x.Value).FirstOrDefault();
i.rating_count = xdoc.Descendants("rating_count").Select(x => x.Value).FirstOrDefault();
i.year = xdoc.Descendants("year").Select(x => x.Value).FirstOrDefault();
i.rated = xdoc.Descendants("rated").Select(x => x.Value).FirstOrDefault();
i.title = xdoc.Descendants("title").Select(x => x.Value).FirstOrDefault();
i.imdb_url = xdoc.Descendants("imdb_url").Select(x => x.Value).FirstOrDefault();
i.plot_simple = xdoc.Descendants("plot_simple").Select(x => x.Value).FirstOrDefault();
i.type = xdoc.Descendants("type").Select(x => x.Value).FirstOrDefault();
i.poster = xdoc.Descendants("poster").Select(x => x.Value).FirstOrDefault();
i.imdb_id = xdoc.Descendants("imdb_id").Select(x => x.Value).FirstOrDefault();
i.also_known_as = xdoc.Descendants("also_known_as").Select(x => x.Value).FirstOrDefault();
i.language = xdoc.Descendants("language").Select(x => x.Value).FirstOrDefault();
i.country = xdoc.Descendants("country").Select(x => x.Value).FirstOrDefault();
i.release_date = xdoc.Descendants("release_date").Select(x => x.Value).FirstOrDefault();
i.filming_locations = xdoc.Descendants("filming_locations").Select(x => x.Value).FirstOrDefault();
i.runtime = xdoc.Descendants("runtime").Select(x => x.Value).FirstOrDefault();
i.directors = xdoc.Descendants("directors").Descendants("item").Select(x => x.Value).ToList();
i.writers = xdoc.Descendants("writers").Descendants("item").Select(x => x.Value).ToList();
i.actors = xdoc.Descendants("actors").Descendants("item").Select(x => x.Value).ToList();
i.genres = xdoc.Descendants("genres").Descendants("item").Select(x => x.Value).ToList();
return i;
}
public class imdbitem
{
public string rating { get; set; }
public string rating_count { get; set; }
public string year { get; set; }
public string rated { get; set; }
public string title { get; set; }
public string imdb_url { get; set; }
public string plot_simple { get; set; }
public string type { get; set; }
public string poster { get; set; }
public string imdb_id { get; set; }
public string also_known_as { get; set; }
public string language { get; set; }
public string country { get; set; }
public string release_date { get; set; }
public string filming_locations { get; set; }
public string runtime { get; set; }
public List<string> directors { get; set; }
public List<string> writers { get; set; }
public List<string> actors { get; set; }
public List<string> genres { get; set; }
}
}
如果你想要电影细节API,那么你可以考虑
OMDB API是开放电影数据库。它 返回IMDB评分,IMDB投票,它也有烂番茄评级。
或者你可以用
My Api Films允许你用IMDB ID搜索,它返回详细的信息,但它有请求限制。
下面是一个简单的解决方案,根据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");
截至2016年8月,IMDB似乎还没有一个直接的API,但我看到很多人在上面写刮刀和东西。下面是一种使用票房热点API访问电影数据的更标准的方法。所有响应都是JSON格式,每天5000次查询,免费
API提供的列表
电影代表作 电影标识符 电影图片 通过IMDB id获取电影 获取最新电影列表 获得新版本 了解电影上映日期 获取特定电影的可用翻译列表 获取电影的视频、预告片和预告片 按标题搜索电影 也支持电视节目,游戏和视频