Python实战之网络与爬虫篇-----如何对比多个库,看哪个更靠谱

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Mind_programmonkey/article/details/86560930

Python实战之网络与爬虫篇-----如何对比多个库,看哪个更靠谱

1.问题拆解

如何对比多个库,看哪个最靠谱?

用哪些参考数值?(生态值、Star数、Fork数)

如何获取数据?(Srar、Fork数)

如何查询需要的数据?(requests库)

2.背景知识

a.开发者网址https://developer.github.com/v3/search/

在里面了解参数情况

b.star数、fork数的获取

扫描二维码关注公众号,回复: 5002979 查看本文章

c.生态数

3.编程实现

# repos_api https://api.github.com/search/repositories?q=django
# ecosys_api https://api.github.com/search/repositories?q=topic:django
# https://api.github.com/search/repositories?q=topic:django+language:python+created:2019-01-01

import  requests

def get_name():
    print('please input separate each name with space')
    names = input()
    return names.split()

def check_repos(names):
    repos_api = 'https://api.github.com/search/repositories?q='
    ecosys_api = 'https://api.github.com/search/repositories?q=topic:'
    for name in names:
        repo_info = requests.get(repos_api+name).json()['items'][0]
        ecosys_info = requests.get(ecosys_api+name).json()['total_count']

        stars = repo_info['stargazers_count']
        forks = repo_info['forks']

        print(name)
        print(stars)
        print(forks)
        print(ecosys_info)
        print('----------------------------')

names = get_name()
check_repos(names)




猜你喜欢

转载自blog.csdn.net/Mind_programmonkey/article/details/86560930