IMDB建议 [英] IMDB suggestions

查看:216
本文介绍了IMDB建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想成为一种自制的算法,是从我的电影列表,将返回电影的准确建议,我还没有看到,我可以喜欢。但是,我需要知道,如果IMDBpy可以返回建议的一部分。
事实上,当你搜索一个电影网站上,您将得到相匹配的那种电影,你搜索的电影列表。

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.

但我不能找到IMDBpy的DOC答案。有没有办法用它来获得建议吗?

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

推荐答案

由于get_movie_recommendations如你所愿(例如它没有12年返回任何从属),你可以用刮的BeautifulSoup建议并没有真正发挥作用。

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

这将打印:

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

之后,你可以搜索那些电影与IMDBpy ...

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

这篇关于IMDB建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆