0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GitHubのStarがいつ付けられたか確認する方法

Posted at

GitHubのREST-APIを用いて情報を表示します.
以下にPythonでのコード例を示します.

import subprocess as sb
from argparse import ArgumentParser


parser = ArgumentParser()
parser.add_argument("--user", required=True, type=str)
parser.add_argument("--repo", required=True, type=str)
args = parser.parse_args()

user_name = args.user
repo_name = args.repo
cmd = f"curl https://api.github.com/repos/{user_name}/{repo_name}/stargazers -H "
cmd += "'Accept: application/vnd.github.v3.star+json' "
cmd += '| grep "starred_at"'
results = sb.check_output(cmd, shell=True).decode().split('"starred_at": ')

cnt = 0
for r in results:
    timestamp = r.split(',')[0][1:-1][:10]
    if "20" in timestamp:
        cnt += 1
        print(f"Star {cnt:0>4}: {timestamp}")

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?