cinemagoer
cinemagoer copied to clipboard
Recommendations returning empty
Hi, your library is really good, thanks for the work.
I want to get the movies under "More Like This", however, I've got an empty result with the code below. I saw #241 , but the fix is not working for me.
IMDbPY 2021.04.18, Python 3.8 and Ubuntu 20.04
from imdb import IMDb
ia = IMDb()
ia.get_movie_recommendations("0133093")
Can confirm, I'm also having the same issue.
Since I couldn't find any working solutions, here's what I've written instead:
import re
from bs4 import BeautifulSoup
import requests
def has_recommendation(tag):
return tag.has_attr('href') and tag['href'].startswith('/title/tt')
def get_recommendations(id):
html = requests.get(f'https://www.imdb.com/title/tt{id}/').content
soup = BeautifulSoup(html, 'html.parser')
recs = soup.find("section", attrs={"data-testid": "MoreLikeThis"})
return [re.findall("title/tt(.......)", obj['href'])[0] for obj in recs.find_all(has_recommendation)]
@alberanid I'm no familiar with your code but maybe this can help you fix the code if there's a problem.