Given an IMDB movie id, how do I programmatically get its poster image?

前端 未结 17 782
礼貌的吻别
礼貌的吻别 2020-12-08 03:17

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

What\'s the url for its poster image?

17条回答
  •  自闭症患者
    2020-12-08 03:39

    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
    

提交回复
热议问题