Created
August 28, 2015 12:53
-
-
Save breyten/665bc700c131e7b04548 to your computer and use it in GitHub Desktop.
Get dutch politicians (mps and executives)
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
#!/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