Skip to content

Instantly share code, notes, and snippets.

@theagoliveira
Last active April 13, 2020 06:33
Show Gist options
  • Save theagoliveira/a605654cd08838e60064752a433c3f31 to your computer and use it in GitHub Desktop.
Save theagoliveira/a605654cd08838e60064752a433c3f31 to your computer and use it in GitHub Desktop.
Python script to bulk download free Springer books
#!/usr/bin/env python
import os
import csv
import urllib
import wget
with open("./textbooks.csv", newline="") as csvfile:
textbooks = csv.DictReader(csvfile)
for book in textbooks:
isbn = book["Print ISBN"]
print(f"\nDownloading {isbn}")
book_dir = f"./{isbn}"
os.mkdir(book_dir)
doi_url = book["DOI URL"]
doi = doi_url.replace("http://doi.org/", "")
pdf_url = f"https://link.springer.com/content/pdf/{doi}.pdf"
epb_url = f"https://link.springer.com/download/epub/{doi}.epub"
try:
wget.download(pdf_url, f"{book_dir}/{isbn}.pdf")
except urllib.error.HTTPError as e:
print("\nNo PDF.")
try:
wget.download(epb_url, f"{book_dir}/{isbn}.epub")
except urllib.error.HTTPError as e:
print("\nNo EPUB.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment