Given an IMDB movie id, how do I programmatically

2020-02-02 09:47发布

movie id tt0438097 can be found at http://www.imdb.com/title/tt0438097/

What's the url for its poster image?

标签: imdb
16条回答
混吃等死
3楼-- · 2020-02-02 10:23

I know that it is way too late, but in my project I used this:-

  1. Use omdbapi, Lets take example of Inception, use www.omdbapi.com/?t=inception it will return a json object.
  2. In that json object get the "Poster" object, it contains the poster for the image.
查看更多
Animai°情兽
4楼-- · 2020-02-02 10:23

Be aware tough, that the terms of service explicitly forbid screenscraping. You can download the IMDB database as a set of text files, but as I understand it, the IMDB movie ID is nowhere to be found in these text files.

查看更多
一夜七次
5楼-- · 2020-02-02 10:24

You can use Trakt API, you have to make a search request with the imdb ID, and the Json result given by Trakt API contains links for two images of that movie (poster and fan art) http://trakt.tv/api-docs/search-movies

查看更多
在下西门庆
6楼-- · 2020-02-02 10:24

Those poster images don't appear to have any correlation to the title page, so you'll have to retrieve the title page first, and then retrieve the img element for the page. The good news is that the img tag is wrapped in an a tag with name="poster". You didn't say what kind of tools you are using, but this basically a screen scraping operation.

查看更多
我命由我不由天
7楼-- · 2020-02-02 10:25

omdbapi works, but I found out you cannot really use these images (because of screen scraping and they are blocked anyway if you use them in an img tag)

The best solution is to use tmdb.org :

1 use your imdbid in this api url:

https://api.themoviedb.org/3/find/tt0111161?api_key=___YOURAPIKEY___&external_source=imdb_id

2 Retrieve the json response and select the poster_path attribute:

"poster_path":"/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg"

3 Prepend this path with "http://image.tmdb.org/t/p/original", and you will have the poster URL that you can use in an img tag :-)

4 You can even change sizes like this:

http://image.tmdb.org/t/p/original/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg
http://image.tmdb.org/t/p/w150/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg
查看更多
登录 后发表回答