import requests from bs4 import BeautifulSoup class FreeboxMoviePlanner: TV_GUIDE_URL = 'https://www.programme-television.org/{}?bouquet=tnt' @staticmethod def _tag_is_film(tag): return ( tag.has_attr('data-nature') and tag['data-nature']=='films-telefilms' ) def getMovies(self, day=''): r = requests.get(self.TV_GUIDE_URL.format(day)) r.raise_for_status() html = BeautifulSoup(r.text, 'html.parser') for channel in html.select('.bloc_cnt'): if len(channel.select('em')): for movie in channel.find_all(FreeboxMoviePlanner._tag_is_film): print("{} - {} ({})".format( movie.select('.texte_titre a')[0]['title'], movie.select('.texte_cat a')[0].string, channel.select('em')[0].string.replace('Programme ','') )) if __name__ == '__main__': fmp = FreeboxMoviePlanner() fmp.getMovies()