IMDB suggestions

拟墨画扇 提交于 2020-01-01 19:58:14

问题


I'd like to make a kind of homemade algorithm, which from a list of all the movies I have, will return accurate suggestions of movies I haven't seen and I could like. But for that I need to know if IMDBpy can return the "suggestions" part. Indeed, when you search for a movie on the web site, you are given a list of movies matching the kind a movie you searched for.

But I can't find an answer on the doc of IMDBpy. Is there a way to get the suggestions with it ?


回答1:


Since get_movie_recommendations doesn't really work as you wish (e.g. it doesn't return anything for 12 Years a Slave), you could scrape the recommendations with BeautifulSoup.

import bs4
import imdb
import requests

src = requests.get('http://www.imdb.com/title/tt2024544/').text
bs = bs4.BeautifulSoup(src)
recs = [rec['data-tconst'][2:] for rec in bs.findAll('div', 'rec_item')]
print recs

This prints:

['1535109', '0790636', '1853728', '0119217', '2334649', '0095953', '1935179', '2370248', '1817273', '1210166', '0169547', '1907668']

After that you can search for those movies with IMDBpy...

ia = imdb.IMDb()
for rec in recs:
  movie = ia.get_movie(rec)
  print movie.movieID, movie.get('title')

... which outputs:

1535109 Captain Phillips
0790636 Dallas Buyers Club
1853728 Django Unchained
0119217 Good Will Hunting
2334649 Fruitvale Station
0095953 Rain Man
1935179 Mud
2370248 Short Term 12
1817273 The Place Beyond the Pines
1210166 Moneyball
0169547 American Beauty
1907668 Flight



回答2:


Link!

There's a line in here:

def get_movie_recommendations(self, movieID):

Maybe this can lead you in the right direction.



来源:https://stackoverflow.com/questions/21485013/imdb-suggestions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!