python_respons
import requests
import pygal
from pygal.style import LightColorizedStyle as LCS,LightenStyle as LS
import matplotlib.pyplot as plt
url='https://api.github.com/search/repositories?q=language:python&sort=stars'
r=requests.get(url)
print("Status code:",r.status_code)
response_dict=r.json()
print("Total repositories:",response_dict['total_count'])
#探索有关仓库的信息
repo_dicts=response_dict['items']
print("Repositories returnes:",len(repo_dicts))
repo_dict=repo_dicts[0]
print("\nSelected information about first repository:")
for repo_dict in repo_dicts:
print('Name:',repo_dict['name'])
print('owner:',repo_dict['owner']['login'])
print('stars:',repo_dict['stargazers_count'])
print('repository:',repo_dict['html_url'])
print('created:',repo_dict['created_at'])
print('updated:',repo_dict['updated_at'])
print('description:',repo_dict['description'])
names,stars=[],[]
for repo_dict in repo_dicts:
names.append(repo_dict['name'])
stars.append(repo_dict['stargazers_count'])
my_style=LS('#333366',base_style=LCS)
chart=pygal.Bar(style=my_style,x_label_rotation=45,show_legend=False)
chart.title='Most-STARRED PYTHON'
chart_x_labels=names
plt.show()
chart.add('',stars)
chart.render_to_file('python_repos.svg')