def check_new_posts_vk():
logging.info('[VK] Started scanning for new posts')
with open(FILENAME_VK, 'rt') as file:
last_id = int(file.read())
if last_id is None:
logging.error('Could not read from storage. Skipped iteration.')
return
logging.info('Last ID (VK) = {!s}'.format(last_id))
try:
feed = get_data()
if feed is not None:
entries = feed["response"][1:]
try:
tmp = entries[0]['is_pinned']
send_new_posts(entries[1:], last_id)
except KeyError:
send_new_posts(entries, last_id)
with open(FILENAME_VK, 'wt') as file:
try:
tmp = entries[0]['is_pinned']
file.write(str(entries[1]['id']))
logging.info('New last_id (VK) is {!s}'.format((entries[1]['id'])))
except KeyError:
file.write(str(entries[0]['id']))
logging.info('New last_id (VK) is {!s}'.format((entries[0]['id'])))
except Exception as ex:
logging.error('Exception of type {!s} in check_new_post(): {!s}'.format(type(ex).__name__, str(ex)))
pass
logging.info('[VK] Finished scanning')
return
Ошибка: ERROR - Exception of type KeyError in check_new_post(): 'response'
Строчка кода: entries = feed["response"][1:]
Не понимаю в чём проблема, пожалуйста помогите :(