"""
作者:Want595
微信号:Want_595
公众号:Want595
"""
import requests
import pygal
from pygal.style import LightColorizedStyle, LightenStyle
url = 'https://api.github.com/search/repositories?q=language:python&sort=stars'
reponse = requests.get(url)
print(reponse.status_code, "响应成功!")
response_dict = reponse.json()
total_repo = response_dict['total_count']
repo_list = response_dict['items']
print("总仓库数:", total_repo)
print('top:', len(repo_list))
names, plot_dicts = [], []
for repo_dict in repo_list:
names.append(repo_dict['name'])
plot_dict = {
'value': repo_dict['stargazers_count'],
'label': str(repo_dict['description'])[:200]+'...',
'xlink': repo_dict['html_url']
}
plot_dicts.append(plot_dict)
my_style = LightenStyle('#333366', base_style=LightColorizedStyle)
my_config = pygal.Config()
my_config.x_label_rotation = -45
my_config.show_legend = False
my_config.title_font_size = 30
my_config.label_font_size = 20
my_config.major_label_font_size = 24
my_config.truncate_label = 15
my_config.show_y_guides = False
my_config.width = 1000
chart = pygal.Bar(my_config, style=my_style)
chart.title = 'GitHub最受欢迎的Python库(前30名)'
chart.x_labels = names
chart.add('', plot_dicts)
chart.render_to_file('30_stars_python_repo.svg')
没有合适的资源?快使用搜索试试~ 我知道了~
基于pygal与requests分析github最受欢迎的python库
共3个文件
py:2个
svg:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 168 浏览量
2024-01-09
12:12:21
上传
评论
收藏 10KB RAR 举报
温馨提示
写在前面 本期内容:基于pygal与requests分析GitHub最受欢迎的30个Python库 实验环境: - python - requests - pygal 实验目标 在现实的应用中,我们经常会使用爬虫分析网络数据,本期博主将用pygal+requests简单对github最受欢迎的30个python库做可视化分析(以stars数量进行排序)。 实验内容 1.配置实验环境 在正式开始之前,我们需要先安装本次实验用到的依赖库: requests:一个Python第三方库,用于发送HTTP请求,并且提供了简洁而友好的API。它支持各种HTTP方法,并具有自动化的内容解码、会话管理、文件上传下载等功能,是进行Web开发和网络爬虫的常用工具。 pygal:一个开源的Python图表库,用于制作统计图表和可视化数据。它支持多种图表类型,包括折线图、柱状图、饼图等,并且具有丰富的样式和可定制性。通过pygal,用户可以轻松地创建漂亮、交互式的图表,用于数据分析和展示。 ……
资源推荐
资源详情
资源评论
收起资源包目录
14-基于pygal与requests分析github最受欢迎的python库.rar (3个子文件)
14-基于pygal与requests分析github最受欢迎的python库
github01.py 707B
github02.py 1KB
30_stars_python_repo.svg 39KB
共 3 条
- 1
资源评论
Want595
- 粉丝: 7w+
- 资源: 71
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功