Last active
December 29, 2015 17:54
-
-
Save skagedal/3a62c94c4ed7d08fedd7 to your computer and use it in GitHub Desktop.
Libris Downloader
This file contains 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&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