2024-04-15
温故知新
00

前言

Github 官方提供了很多 API ,可以用于获取很多 Github 上公开的用户和仓库信息。

这是官方文档:GitHub REST API documentation - GitHub Docs

其中有根据用户名获取用户详细信息的接口,可以拿到指定用户的FollowerFollowingPublicRepos等等的数量,但奇怪的是,拿不到该用户的 Starred 仓库数量。

如下是获取用户信息接口的响应数据示例:

json
{ "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false, "name": "monalisa octocat", "company": "GitHub", "blog": "https://github.com/blog", "location": "San Francisco", "email": "[email protected]", "hireable": false, "bio": "There once was...", "twitter_username": "monatheoctocat", "public_repos": 2, "public_gists": 1, "followers": 20, "following": 0, "created_at": "2008-01-14T04:33:35Z", "updated_at": "2008-01-14T04:33:35Z" }

当然想要获取也有别的方法,如通过 Starred 的仓库列表接口汇总,最后得出一个总数,那就是该用户的总 Starred 数量,但是这样有一个问题,那就是不确定要调用多少次接口。由于Github的分页接口最大单页数量是100,所以才用此方法,Starred的仓库越多,相应需要调用接口的次数越多。

有没有只需要调用一次接口就可以拿到 Starred 数量的方法呢?有大佬找到了方法!

2024-04-15
温故知新
00

简介

本文用于记录Dockerfile中 COPY 指令的常见用法。

COPY大家可能都知道,是用来将文件复制到容器内的,但是针对不同的文件有不同的用法。

本文目前主要记录了:

  • 单文件复制
  • 文件夹复制
  • 多文件复制
  • 镜像文件复制
2024-04-14
老年痴呆
00

简介

本文用于记录可以手动实现的一些工具,等到啥时候有空了,自己实现以下,就不用在网上找了。

2024-04-14
温故知新
00

简介

本文用于记录一些正则表达式。

主要用于以后需要时查阅,当然也可以温故而知新。

2024-04-13
温故知新
00

引言

Java 编程中,NullPointerException(空指针异常)是一种常见的运行时异常,经常困扰着开发人员。本文将探讨 NullPointerException 的原因、解决方法以及如何避免这种异常的发生。