Skip to content

Instantly share code, notes, and snippets.

@breyten
Created August 28, 2015 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save breyten/665bc700c131e7b04548 to your computer and use it in GitHub Desktop.
Save breyten/665bc700c131e7b04548 to your computer and use it in GitHub Desktop.
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
soup = BeautifulSoup(resp.content)
politicians = []
for row in soup.findAll('div', 'member-info', recursive=True):
politician = {
'name': row.find('h2').text,
'party': row.find('img')['alt'].split(u' ')[-1].replace(
u'(', u'').replace(u')', u'')
}
politicians.append(politician)
return politicians
def get_exeuctive_office(session):
url = u'http://www.rijksoverheid.nl/regering/bewindspersonen'
resp = session.get(url)
if resp.status_code != 200:
return None
soup = BeautifulSoup(resp.content)
politicians = []
for row in soup.find('div', 'people').findAll('li', recursive=True):
politician = {
'name': row.find('h2').text,
}
politicians.append(politician)
return politicians
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment