Created
October 10, 2017 11:54
-
-
Save datastory/6e4d0fb4acbd19f7056a26122d7fe337 to your computer and use it in GitHub Desktop.
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
# coding: utf-8 | |
import requests | |
import os | |
import json | |
import pandas as pd | |
for i in range(0, 34): | |
url = 'https://cro.justice.cz/verejnost/api/funkcionari?sort=created&order=DESC&page=' + str(i) + '&pageSize=1000' | |
r = requests.get(url) | |
with open('./scratch/p_' + str(i) + '.json', 'wb') as f: | |
f.write(r.content) | |
out = pd.DataFrame() | |
for file in os.listdir('./scratch'): | |
with open('./scratch/' + file, encoding='utf-8') as f: | |
temp = json.load(f) | |
if len(temp['items']) > 0: | |
out = out.append(temp['items'], ignore_index=True) | |
out = out.drop('workingPositions', axis=1) | |
out.drop_duplicates(inplace=True) | |
out.to_excel('./osoby.xlsx') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment