Github: Can I see the number of downloads for a repo?

后端 未结 17 1091
甜味超标
甜味超标 2020-11-28 02:35

In Github, is there a way I can see the number of downloads for a repo?

17条回答
  •  日久生厌
    2020-11-28 03:07

    I ended up writing a scraper script to find my clone count:

    #!/bin/sh
    #
    # This script requires:
    #   apt-get install html-xml-utils
    #   apt-get install jq
    #
    USERNAME=dougluce
    PASSWORD="PASSWORD GOES HERE, BE CAREFUL!"
    REPO="dougluce/node-autovivify"
    
    TOKEN=`curl https://github.com/login -s -c /tmp/cookies.txt | \
         hxnormalize | \
         hxselect 'input[name=authenticity_token]' 2>/dev/null | \
         perl -lne 'print $1 if /value=\"(\S+)\"/'`
    
    curl -X POST https://github.com/session \
         -s -b /tmp/cookies.txt -c /tmp/cookies2.txt \
         --data-urlencode commit="Sign in" \
         --data-urlencode authenticity_token="$TOKEN" \
         --data-urlencode login="$USERNAME" \
         --data-urlencode password="$PASSWORD" > /dev/null
    
    curl "https://github.com/$REPO/graphs/clone-activity-data" \
         -s -b /tmp/cookies2.txt \
         -H "x-requested-with: XMLHttpRequest" | jq '.summary'
    

    This'll grab the data from the same endpoint that Github's clone graph uses and spit out the totals from it. The data also includes per-day counts, replace .summary with just . to see those pretty-printed.

提交回复
热议问题