Created
January 13, 2015 21:13
-
-
Save JonathanReeve/31f5ace36a6d6ddfc375 to your computer and use it in GitHub Desktop.
GitHub issue scraper to print issues from multiple repositories containing a label
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Not yet working! | |
# -*- coding: utf-8 -*- | |
# <nbformat>3.0</nbformat> | |
# <codecell> | |
import requests | |
import json | |
# <codecell> | |
def getIssues(repos): | |
# build list of sites | |
sites = ['https://api.github.com/repos/mlaa/' + repo + '/issues?labels=meeting-agenda&state=open' for repo in repos] | |
issues = [] | |
for site in sites: | |
response = requests.get(site) | |
#TODO: check for success | |
decoded = json.loads(response.text) | |
issues.append(decoded) | |
return issues | |
def printTable(issues, columns): | |
print( '<table>' ) | |
for issue in issues: | |
print( '<tr>' ) | |
for column in columns: | |
print( '<td>' ) | |
if column in issue[0]: | |
print( issue[0][column] ) | |
else: | |
print( 'n/a' ) | |
print( '</td>' ) | |
print( '</tr>' ) | |
print( '</table>' ) | |
# <codecell> | |
repos = ['cbox-mla', 'cbox-auth', 'cac-advanced-profiles', 'commons', 'cbox-mla-blog'] | |
issues = getIssues(repos) | |
columns = ['number', 'title', 'body'] | |
printTable(issues, columns) | |
# <codecell> | |
issues[0][0] | |
# <codecell> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment