La Comisión Económica para América Latina y el Caribe(CEPAL) fue creada en 1948 para realizar investigaciones y propuestas de desarrollo en él ambiento, económico, político y social en los países de la región Latinoamérica y caribeña. En su sitio web podremos encontrar una infinidad de producciones teóricas y metodológicas en los ámbitos susodichos.[1]
The Economic Commission for Latin America and the Caribbean (ECLAC) was created in 1948 to carry out research and development proposals in the economic, political and social environment in the countries of the Latin American and Caribbean region. In its web site we can find an infinity of theoretical and methodological productions in the above mentioned fields.[1]
Para descargar sus publicaciones nos dirigiremos al siguiente enlace https://www.cepal.org/es/publications/list , ingresamos al sitio web y seleccionamos la investigación de interés. Para fines prácticos voy a descargar la siguiente publicación:
To download their publications go to the following link https://www.cepal.org/es/publications/list , enter the website and select the research of interest. For practical purposes I will download the following publication:
¿Cómo puede descargar con Python? Es muy simple, este programa lo ejecuta desde la terminal de Linux o CMD de Windows, una vez que lo ejecute le preguntara que ingrese el link de la publicación, usted simplemente debe ir a su navegador-estoy usando Vivaldi- dirigir el mouse al título de la publicación, presiona el botón derecho del mouse sobre el título y copia la dirección del enlace. El último paso es pegar el enlace en el terminal de Linux, presiona Enter y espera que finalice la descarga.
How can you download with Python? It is very simple, this program can be executed from the terminal of Linux or CMD of Windows, once it executes it will ask you to enter the link of the publication, you simply must go to your navigator - I am using Vivaldi - direct the mouse to the title of the publication, press the right button of the mouse and copy the address of the link. The last step is to paste the link in it finishes of Linux, we press Enter and we wait that the download finishes.
Imágenes del proceso y resultado de la descarga || Images of the download process and result
Para detener la ejecución del programa, presione Ctrl+C o simplemente cierre la ventana.
Bueno, eso es todo... Esperen, tampoco me voy a ir sin dejarles el código.😆
To stop the program execution, press Ctrl+C or simply close the window.
Well, that's all... Wait, I'm not going to leave without leaving you the code either 😆.
import requests
from bs4 import BeautifulSoup
while True:
link= input('Ingresa el link para descargar la publicación: ')
urltopdf = (link)
get_url = requests.get(urltopdf)
html = BeautifulSoup(get_url.content, 'lxml')
fpdf = html.find("a",{'class': 'dropdown-item'},href=True) #find pdf file
pdf_file = (fpdf.get('href')) #obtained pdf file
rpdf = requests.get(pdf_file)#Take content from converter in pdf file
s_u = pdf_file.split("/")[8]
with open((s_u) , 'wb') as file:
file.write(rpdf.content)
file.close()
print(' Descarga finalizada')
¿Qué le parece esta herramienta? Déjame saberlo con tú comentario.
What do you think of this tool? Let me know with your comment.
gracias