python - IMDB suggestions -


i'd make kind of homemade algorithm, list of movies have, return accurate suggestions of movies haven't seen , like. need know if imdbpy can return "suggestions" part. indeed, when search movie on web site, given list of movies matching kind movie searched for.

but can't find answer on doc of imdbpy. there way suggestions ?

since get_movie_recommendations doesn't work wish (e.g. doesn't return 12 years slave), scrape recommendations 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:] rec in bs.findall('div', 'rec_item')] print recs 

this prints:

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

after can search movies imdbpy...

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

... outputs:

1535109 captain phillips 0790636 dallas buyers club 1853728 django unchained 0119217 hunting 2334649 fruitvale station 0095953 rain man 1935179 mud 2370248 short term 12 1817273 place beyond pines 1210166 moneyball 0169547 american beauty 1907668 flight 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -