-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfroide-crawler.py
More file actions
executable file
·39 lines (30 loc) · 855 Bytes
/
Copy pathfroide-crawler.py
File metadata and controls
executable file
·39 lines (30 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This is a small utility that helps to retrieve
all FOIA requests from FragDenStaat.de.
"""
import sys
from urllib.parse import urljoin
import requests
import json
BASE_URL = 'https://fragdenstaat.de'
START = '/api/v1/request/?offset=0&limit=100'
def get_requests():
i = 0
with sys.stdout as f:
url = urljoin(BASE_URL, START)
while True:
i += 100
r = requests.get(url)
assert r.ok
json_content = r.json()
for el in json_content['objects']:
f.write(json.dumps(el))
f.write('\n')
if json_content['meta']['next']:
url = urljoin(BASE_URL, json_content['meta']['next'])
else:
return
if __name__ == '__main__':
get_requests()