Connecting to IMDB

2019-03-08 20:26发布

Has any one done this before? It would seem to me that there should be a webservice but i can't find one. I am writing an application for personal use that would just show basic info from IMDB.

9条回答
叛逆
2楼-- · 2019-03-08 20:39

The libraries for IMDb seem quite unreliable at present and highly inefficient. I really wish IMDb would just create a webservice.

After a bit of searching I found a reasonable alternative to IMDb. It provides all the basic information such as overview, year, ratings, posters, trailers etc.:

The Movie Database (TMDb).

It provides a webservice with wrappers for several languages and seems reliable so far. The search results have been, for myself, more accurate as well.

查看更多
forever°为你锁心
3楼-- · 2019-03-08 20:44

IMDB prohibits scrapers, and change the page layout every once in a while, so parsing HTML is an option, but be prepared to adjust your code 2-3 times a year (been there, done that, given up). They do have a fee-based service giving the full access to the data, but you'll also need to explain what is it for, and convince them you are not building a competitive website (I had a link to that, but it seems to have changed and can't find it now).

查看更多
Deceive 欺骗
4楼-- · 2019-03-08 20:45

Now there's is an (undocumented) API like http://www.imdb.com/xml/find?json=1&q=Harry+Potter. See Does IMDB provide an API?

查看更多
The star\"
5楼-- · 2019-03-08 20:51

Here is my own solution using RegEx:

private const string UglyMovieRegex = "(?<=5>|3>)(Cast|Director:|Fun\\sStuff|Genre:|Plot:|Runtime:|Tagline:|Writers:)"
                                                + "|href=\"[\\w\\d/]+?(Genres|name|character)/([\\w]+?)/\".*?>([.\\-\\s\\w]+)</a>"
                                                + "|(?<=h\\d>)([.\\w\\s'\\-\"]+)(?=<a\\sc|</d|\\|)";

Regex MovieData = new Regex (UglyMovieRegex, RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline );
查看更多
我欲成王,谁敢阻挡
6楼-- · 2019-03-08 20:51

Another alternative is to run the IMDB database on your local machine. Java Movie Database imports the IMDB database files, converts them and provides a locally-accessible copy of IMDB. IMDB has some functionality which Java Movie Database does not have and visa-versa but if what you're looking for is quick access to all the data it might be worth giving this a try.

查看更多
Root(大扎)
7楼-- · 2019-03-08 20:54

Though this was posted over two years ago, here is a simple python code

import urllib2

movie_id = raw_input('Enter the ID of the movie: ')
json = urllib2.urlopen('http://imdbapi.com/?i=' + movie_id + '&r=json')

print json.read()

save as imdb.py and then run as in shell or terminal or whatever

if you want xml data just replace json with xml

please note that this is using the imdbapi.com website to return a json result visit that website to view more options.

查看更多
登录 后发表回答