项目作者: fredericojordan

项目描述 :
📊Scripts to gather github user statistics
高级语言: Python
项目地址: git://github.com/fredericojordan/github-stats.git
创建时间: 2019-06-11T20:20:01Z
项目社区:https://github.com/fredericojordan/github-stats

开源协议:

下载


github-stats

Code style: black

Python scripts to gather github statistics.

Requirements

In order to run the scripts, we need to install dependecies and list the usernames we’ll be analysing.

Installing dependencies

Run the following command on your terminal:

  1. pip install -r requirements.txt

Github API Token

In order authenticate the API requests, we must first generate a Github personal token,
containing the read:user scope.

Then we just set the GITHUB_TOKEN environment variable:

  1. GITHUB_TOKEN=<token>

or in fish:

  1. set -x GITHUB_TOKEN "<token>"

Github username list

There are two different ways to determine what users we will be scraping:

Using usernames.txt file

usernames.txt is a text file listing github usernames we are interested in gathering statistics from.

It should have one username per line, for example:

  1. fredericojordan
  2. gvanrossum

Using GITHUB_USERNAMES environment variable

If a usernames.txt file is not found, the second option is using a GITHUB_USERNAMES env var.

The usernames are separated by a comma, for example (in bash):

  1. GITHUB_USERNAMES="fredericojordan,gvanrossum"

or in fish:

  1. set -x GITHUB_USERNAMES "fredericojordan,gvanrossum"

Running the script

Simply run the stats.py script from your terminal:

  1. python stats.py

Output:

  1. 1. (2855) fredericojordan
  2. 2. (1040) gvanrossum

(Optional) Start web server

We may also use gunicorn to serve a simple static web page displaying the statistics:

  1. gunicorn server:app

and then navigate to localhost:8000 on a browser of your choice.