我如何获得去年我贡献的所有GitHub项目的列表?

the*_*ory 33 api events github

我意识到我可以点击https://api.github.com/users/:user_id/repos获取我拥有或分叉的所有回购的清单.但我想要做的是弄清楚我去年所做的所有项目(提交,拉取请求,问题等).该事件API让我得到最后的300个事件,但我已经贡献了很多在过去十二个月不止于此.这可能吗?

the*_*ory 5

由于鸣叫@caged,我写了这个Perl脚本来遍历在几个月我的贡献

use v5.12;
use warnings;
use utf8;
my $uname = 'theory';

my %projects;
for my $year (2012..2014) {
    for my $month (1..12) {
        last if $year == 2014 && $month > 1;
        my $from = sprintf '%4d-%02d-01', $year, $month;
        my $to   = sprintf '%4d-%02d-01', $month == 12 ? ($year + 1, 1) : ($year, $month + 1);
        my $res = `curl 'https://github.com/$uname?tab=contributions&from=$from&to=$to' | grep 'class="title"'`;
        while ($res =~ /href="([^"?]+)/g) {
            my (undef, $user, $repo) = split m{/} => $1;
            $projects{"$user/$repo"}++;
        }
    }
}

say "$projects{$_}: $_" for sort keys %projects;
Run Code Online (Sandbox Code Playgroud)

是的,HTML抓取有点难看,但是可以满足我的需要。

  • 我再次需要这个,但遗憾的是它不再工作了,因为现在通过 JS 加载了各种位。:-( (3认同)