简体   繁体   中英

How to get all repositories of a specific GitHub user

如何使用简单的HTTP库(例如urllib2请求 )获取特定GitHub用户的所有存储库( > 100 )。

To get more than 100 repositories from GitHub it's necessary to follow the links inside the link header .

import requests

def get_repositories(url):
    result = []
    r = requests.get(url=url)
    if 'next' in r.links :
        result += get_repositories(r.links['next']['url'])

    for repository in r.json():
        result.append(repository.get('name'))

    return result

url = "https://api.github.com/users/stackforge/repos"
print get_repositories(url)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM