转载 https://zhuanlan.zhihu.com/p/150889781
如何优雅地管理 GitHub 上 star 的项目
GitHub Star管理工具很多,或是插件,或是网站.我想,纯文本还是最简单的方法,如果把它以一定格式导出来,发布到知乎专栏上可能更方便查看和分享,下面谈做法.
安装PyGithub
pip install PyGithub
导出stars.csv
这里使用github上的export-stars项目来导出. github.com/JeffCarpenter/export-stars
GH_USER=yourGithubusername python3 export_stars.py > stars.csv
由csv文本转markdown格式并用split分割
stars.csv内容例如
1 | https://github.com/TheAlgorithms/C,All Algorithms implemented in C |
1 | sed "s#\(https://github.com/\)\([^,]*\),#- [\2](\1\2)#g" test.txt |
转换之后
1 | - [TheAlgorithms/C](https://github.com/TheAlgorithms/C)All Algorithms implemented in C |
sed可以用-i选项直接改源文件.这里只列了三行,假设stars.csv里有1800行,那么-l参数设300可以把文件拆成 6份.我这样做了,一个个以markdown导出来,发在另一个专栏中,感兴趣的小伙伴可以看看.
1 | sed -i "s#\(https://github.com/\)\([^,]*\),#- [\2](\1\2)#g" stars.csv |