Skip to content

Instantly share code, notes, and snippets.

View breyten's full-sized avatar

Breyten Ernsting breyten

View GitHub Profile
@breyten
breyten / combine_results.py
Created August 28, 2015 14:28
combine_results.py
party_counts = sorted([
{'party': p, 'count': get_party_count(p, session)} for p in parties],
key=lambda x: x['count'])
pprint(party_counts)
all_people = politicians + executives
politician_counts = sorted([
{'politician': p, 'count': get_politician_count(p, session)} for p in all_people],
key=lambda x: x['count'])
@breyten
breyten / query_npo_backstage.py
Last active August 28, 2015 13:07
Query NPO backstage API for the name of a person.
#!/usr/bin/env python
import requests
from BeautifulSoup import BeautifulSoup
NPO_BACKSTAGE_BASE_URL = 'http://backstage-api.npo.nl'
NPO_BACKSTAGE_ENDPOINT_SEARCH = '/v0/search'
def get_politician_count(politician, session):
SEARCH_DATA = {
@breyten
breyten / get_dutch_politicians.py
Created August 28, 2015 12:53
Get dutch politicians (mps and executives)
#!/usr/bin/env python
import requests
from BeautifulSoup import BeautifulSoup
def get_politicians(session):
url = u'http://www.tweedekamer.nl/kamerleden/alle_kamerleden'
resp = session.get(url)
if resp.status_code != 200:
return None