Skip to content

Instantly share code, notes, and snippets.

@127-0-0-1
Forked from dchaplinsky/declarations_api.py
Created July 20, 2016 04:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 127-0-0-1/75051fd817207ecbdff03811f53289ff to your computer and use it in GitHub Desktop.
Save 127-0-0-1/75051fd817207ecbdff03811f53289ff to your computer and use it in GitHub Desktop.
Simple example of how to export all assets declarations from declarations.com.ua website.
import requests
import json
from time import sleep
data = []
print("Fetching page #%s" % 1)
r = requests.get("http://declarations.com.ua/search?format=json").json()
data += r["results"]["object_list"]
for page in range(2, r["results"]["paginator"]["num_pages"] + 1):
sleep(0.5)
print("Fetching page #%s" % page)
subr = requests.get(
"http://declarations.com.ua/search?format=json&page=%s" % page).json()
data += subr["results"]["object_list"]
print("Declarations exported %s" % len(data))
with open("feed.json", "w") as fp:
json.dump(data, fp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment