import pygal
import requests
from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS
url='https://api.github.com/search/repositories?q=language:python&sort=stars'
r = requests.get(url)
print('States code:', r.status_code)
# 将API响应存起来
response_dict = r.json()
print("Total repositories:", response_dict['total_count'])
#
repo_dicts = response_dict["items"]
# print(response_dict.keys())
print("Repositories returned:", len(repo_dicts))
'''
repo_dict = repo_dicts[0]
print("\nKeys:", len(repo_dict))
for key in sorted(repo_dict.keys()):
print(key)
'''
print("\nSelected information about first repository:")
names, stars = [], []
plot_dicts = []
for repo_dict in repo_dicts:
print("\nName:", repo_dict['name'])
names.append(repo_dict['name'])
print("Owner:", repo_dict['owner'])
print("Stars:", repo_dict['stargazers_count'])
stars.append(repo_dict['stargazers_count'])
# 'NoneType' object has no attribute 'decode' ,repo_dict['description']中