Skip to content

Instantly share code, notes, and snippets.

@datastory
Created October 10, 2017 11:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save datastory/6e4d0fb4acbd19f7056a26122d7fe337 to your computer and use it in GitHub Desktop.
Save datastory/6e4d0fb4acbd19f7056a26122d7fe337 to your computer and use it in GitHub Desktop.
# 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