Skip to content

Instantly share code, notes, and snippets.

@skagedal
Last active December 29, 2015 17:54
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 skagedal/3a62c94c4ed7d08fedd7 to your computer and use it in GitHub Desktop.
Save skagedal/3a62c94c4ed7d08fedd7 to your computer and use it in GitHub Desktop.
Libris Downloader
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&start=' + str(counter)
print ("Fetching: " + url)
data = urlopen(url).read()
if not data.find(b"<record>") >= 0:
print("No more records!")
break
with open(str(counter) + ".xml", "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