Forked from christopherkullenberg/swepubscraper.py
Created
December 29, 2015 22:50
-
-
Save skagedal/dbff704fa28b4db36ab6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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