Last active
October 14, 2016 17:18
-
-
Save ricardojob/ceb69d9d3723ce2824f7f809aa2cb4cf to your computer and use it in GitHub Desktop.
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
import re | |
import requests | |
def downloadToFile(url): | |
local = url.split('/')[-1] | |
r = requests.get(url) | |
f = open(local, 'wb') | |
for chunk in r.iter_content(chunk_size=512 * 1024): | |
if chunk: | |
f.write(chunk) | |
f.close() | |
return | |
ext = ".epub" | |
listOfBooks={ | |
'http://www.oreilly.com/programming/free/hadoop-with-python.csp', | |
'http://www.oreilly.com/programming/free/microservices-for-java-developers.csp' | |
} | |
for key in listOfBooks: | |
retorno = re.search(r"free/(.*?).csp", key).group(0) | |
book = retorno.split('free/')[1].strip('.csp') | |
fileName ='http://www.oreilly.com/programming/free/files/'+book+ext | |
downloadToFile(fileName); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment