如何对比多个库,看看那个最靠谱
思路
参考的数值
如何获取数据
https://api.github.com/search/repositories?q=django
https://api.github.com/search/repositories?q=bottle
https://api.github.com/search/repositories?q=flask
https://api.github.com/search/repositories?q=django&sort=stars&order=asc
查询数据
开始搞
- postman请求:
https://api.github.com/search/repositories?q=bottle
查生态的api接口
https://api.github.com/search/repositories?q=topic.django
写代码
# API:
'''
以django为例:
https://api.github.com/search/repositories?q=django
https://api.github.com/search/repositories?q=topic:django #生态
'''
import requests
def get_names():
print('Separate each name with Space')
names = input()
return names.split()
def check_repos(names):
repo_api = "https://api.github.com/search/repositories?q="
ecosys_api = "https://api.github.com/search/repositories?q=topic:"
for name in names:
ecosys_info = requests.get(ecosys_api+name).json()['total_count']
repo_info = requests.get(repo_api+name).json()['items'][0]
stars = repo_info['stargazers_count']
forks = repo_info['forks_count']
print('Stars:'+str(stars))
print('Forks:'+str(forks))
print('Ecosys:'+str(ecosys_info))
print("--------------------")
name = get_names()
check_repos(name)