IMDB suggestions

懵懂的女人 提交于 2019-12-04 21:23:56

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

Link!

There's a line in here:

def get_movie_recommendations(self, movieID):

Maybe this can lead you in the right direction.

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