Skip to content

Instantly share code, notes, and snippets.

@christopherkullenberg
Created December 29, 2015 18:28
Show Gist options
  • Save christopherkullenberg/4bde1af6108da4543ebd to your computer and use it in GitHub Desktop.
Save christopherkullenberg/4bde1af6108da4543ebd to your computer and use it in GitHub Desktop.
from urllib.request import urlopen
counter = 1
while True:
url = 'http://libris.kb.se/xsearch?d=swepub&hitlist&q=l%C3%A4ros%C3%A4te%3agu&f=ext&spell=true&hist=true&n=200&format=json&start=' + str(counter)
print ("Fetching: " + url)
data = urlopen(url).read()
if not data.find(b'"identifier"') >= 0:
print("No more records!")
break
with open(str(counter) + ".json", "wb") as outputfile:
print("Writing file...")
outputfile.write(data)
counter += 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment