Created
January 4, 2020 13:17
-
-
Save nruigrok/5c10619e14378323ee565b9d5993eb80 to your computer and use it in GitHub Desktop.
kamervragen van api
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
import urllib.request | |
import json | |
url = 'https://www.openkamer.org/api/kamervraag/?format=json&offset=1' | |
req = urllib.request.Request(url) | |
##parsing response | |
r = urllib.request.urlopen(req).read() | |
cont = json.loads(r.decode('utf-8')) | |
def read_doc(doc): | |
url = doc['url'] | |
title = doc['document']['title_full'] | |
date = doc['document']['date_published'] | |
vragen = [] | |
for v in doc['vragen']: | |
text = v['text'] | |
vragen.append(text) | |
submitters = [] | |
for s in doc['document']['submitters']: | |
name = s['person']['fullname'] | |
submitters.append(name) | |
partijen = [] | |
for p in doc['document']['submitters']: | |
partij = p['party']['name_short'] | |
partijen.append(partij) | |
indieners = dict(zip(submitters, partijen)) | |
footnotes = [] | |
links =[] | |
for f in doc['document']['foot_notes']: | |
fn = f['text'] | |
footnotes.append(fn) | |
link = f['url'] | |
if not link: | |
link ="-" | |
links.append(link) | |
voetnoten = dict(zip(footnotes,links)) | |
print(voetnoten) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment