在 python 中使用 git 添加用户的所有回购

Add all the repos from a user using git in python

我有一个函数:def get_repos(user)。我想要的是将该用户的 public 存储库名称从 Github 添加到 Python 中的 set()。有办法吗?

是的,如“Build a Dynamic Portfolio With the Github API" from Ramki Pitchala, using, as commented, the Users REST API:

所示
def getRepos():
    try:
        url = "https://api.github.com/users/Ramko9999/repos"
        headers = {"Accept":"application/vnd.github.mercy-preview+json"}
        repos = requests.get(url, headers=headers, auth=(USERNAME,TOKEN)).json()
        projects = []
        for repo in repos:
            if repo["homepage"]:
                project = {
                    "id": repo["id"],
                    "name": repo["name"],
                    "url": repo["html_url"],
                    "description": repo["description"],
                    "topics":repo["topics"],
                    "images": repo["homepage"].split(";")
                }
                projects.append(project)
        return {"projects": projects, "error": False}
    except Exception as e:
        return {"error": True, "message": str(e)}

(将Ramko9999替换为您需要的实际用户名)