Skip to content

Instantly share code, notes, and snippets.

@mkfsn
Created March 11, 2020 04:32
Show Gist options
  • Save mkfsn/c7159cfc9c096104a3b1a91165efd3b7 to your computer and use it in GitHub Desktop.
Save mkfsn/c7159cfc9c096104a3b1a91165efd3b7 to your computer and use it in GitHub Desktop.
from pyquery import PyQuery as pq
import requests
users = {}
resp = requests.get("https://github.com/tokyo-metropolitan-gov/covid19/pull/1055")
for i in pq(resp.text).find("a.author[data-hovercard-type="+'"user"'+"]"):
user = pq(i).text()
url = pq(i).attr('href')
if user not in users:
r = requests.get('https://api.github.com/users'+url).json()
try:
location = r["location"]
except:
print("raw:", r)
users[user] = {'count': 0, 'location': location}
users[user]['count']+=1
for name, u in users.items():
print ("%13s:\t%s %d" % (name, u['location'], u['count']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment