Подскажите ,пожалуйста, как правильно получить информацию из issues по ключам 'number' и 'repository_url'. Толи я запрос по апи не так делаю и мне приходит список ,а не словарь, толи парсю не правильно...
import requests
import datetime
import sys
def get_trending_repositories(top_size):
date_now = datetime.datetime.now()
last_week = (date_now - datetime.timedelta(days=7)).strftime('%Y-%m-%d')
filter_params = {'sort': 'stars',
'order': 'desc',
'page': '1'}
filter_params['q'] = 'created:>{}'.format(last_week)
filter_params['per_page'] = '{}'.format(top_size)
url = 'https://api.github.com/search/repositories'
repositories = requests.get(url, params=filter_params).json()['items']
return repositories
def get_open_issues_amount(repositories):
for number, repo in enumerate(repositories, 1):
url = 'https://api.github.com/repos/{}/issues'.format(repo['full_name'])
issues = requests.get(url).json()
print('{}) \t open issues:{} \t {}'.format(
number, issues['number'], issues['repository_url']))
if __name__ == '__main__':
if len(sys.argv) > 1:
input_amount = sys.argv[1]
else:
input_amount = input('Enter amount repositories: ')
filter_repositories = get_trending_repositories(input_amount)
get_open_issues_amount(filter_repositories)
При попытке вывести на печать выдает ошибку:
Traceback (most recent call last):
File "github_trending.py", line 49, in <module>
get_open_issues_amount(filter_repositories)
File "github_trending.py", line 28, in get_open_issues_amount
number, issues['number'], issues['repository_url']))
TypeError: list indices must be integers or slices, not str