import requests import time kinopoisk_api_url='https://kinopoiskapiunofficial.tech/api/v2.2' # Используется неофициальное API кинопоиска, дефолтный лимит 500 запросов. with open(".auth_kinopoisk", mode='rt') as key_file: token = key_file.read().replace('\n', '') def get_kinopoisk_movie(film=list): films_resolved = [] for i in film: headers = { "X-API-KEY": token, } r = requests.get(kinopoisk_api_url + "/films/" + i, headers=headers) if r.status_code == 200: film_data = r.json() films_resolved.append((film_data['type'], film_data['year'], film_data['nameOriginal'], film_data['nameRu'])) elif r.status_code in (400, 404): films_resolved.append(("404",)) else: continue time.sleep(0.2) return films_resolved