-
-
Save beingsane/5c1d9a3eb22d15d80cf7d6f575615f4c to your computer and use it in GitHub Desktop.
Download dos livros grátis da Springer
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
import requests | |
import csv | |
import os | |
# Script para download dos livros: | |
# https://www.hardmob.com.br/threads/744521-Springer-PDF-Livros-da-Editora-Springer-DE-GRACA-negocios-engenharia-medicina | |
lista_livros = requests.get( | |
"https://docs.google.com/spreadsheets/d/1HzdumNltTj2SHmCv3SRdoub8SvpIEn75fa4Q23x0keU/export?format=csv&id=1HzdumNltTj2SHmCv3SRdoub8SvpIEn75fa4Q23x0keU" | |
) | |
planilha = csv.reader( | |
lista_livros.content.decode('utf-8').splitlines(), | |
delimiter=',' | |
) | |
livros = list(planilha) | |
livros.pop(0) | |
for livro in livros: | |
nome_livro = livro[0].replace('/', '-') | |
doi_isbn = ( | |
livro[17].split('/')[3] + '%2F' + livro[17].split('/')[4] | |
) | |
link_download = ( | |
'https://link.springer.com/content/pdf/' + doi_isbn | |
) | |
pasta_genero = './{}/'.format( | |
livro[19].split(';')[0] | |
) | |
arquivo_a_salvar = ( | |
pasta_genero + nome_livro + '.pdf' | |
) | |
if not os.path.isdir(pasta_genero): | |
print("Criando diretório: {}".format(pasta_genero)) | |
os.mkdir(pasta_genero) | |
print("Fazendo download do livro: {} na pasta {}".format( | |
nome_livro, pasta_genero)) | |
download = requests.get(link_download) | |
open(arquivo_a_salvar, | |
'wb').write(download.content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment