Ejemplo de traducción de Notebook de Jupyter a artículo de WordPress

Hemos seguido el protocolo establecido en esta WEB por Andy Challis para realizar la conversión del fichero HTML generado por la exportación de un Notebook a fichero HTML.

Para generar el fichero uso:

!jupyter nbconvert –template basic –to html “00_TablaPeriodica.ipynb” –output “.\00_TablaPeriodica_basic.html”

y pego el resultado del HTML en un bloque de HTML personalizado.

In [2]:
!pip install gtts
Collecting gtts
[notice] A new release of pip is available: 24.2 -> 24.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip
  Downloading gTTS-2.5.3-py3-none-any.whl.metadata (4.1 kB)
Requirement already satisfied: requests<3,>=2.27 in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from gtts) (2.31.0)
Requirement already satisfied: click<8.2,>=7.1 in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from gtts) (8.1.7)
Requirement already satisfied: colorama in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from click<8.2,>=7.1->gtts) (0.4.4)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from requests<3,>=2.27->gtts) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from requests<3,>=2.27->gtts) (2.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from requests<3,>=2.27->gtts) (1.26.3)
Requirement already satisfied: certifi>=2017.4.17 in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from requests<3,>=2.27->gtts) (2020.12.5)
Downloading gTTS-2.5.3-py3-none-any.whl (29 kB)
Installing collected packages: gtts
Successfully installed gtts-2.5.3
In [4]:
!pip install wikipedia
Collecting wikipedia
  Downloading wikipedia-1.4.0.tar.gz (27 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: beautifulsoup4 in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from wikipedia) (4.9.3)
Requirement already satisfied: requests<3.0.0,>=2.0.0 in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from wikipedia) (2.31.0)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from requests<3.0.0,>=2.0.0->wikipedia) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from requests<3.0.0,>=2.0.0->wikipedia) (2.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from requests<3.0.0,>=2.0.0->wikipedia) (1.26.3)
Requirement already satisfied: certifi>=2017.4.17 in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from requests<3.0.0,>=2.0.0->wikipedia) (2020.12.5)
Requirement already satisfied: soupsieve>1.2 in d:\sw\programacion\python\wpy64-3920\python-3.9.2.amd64\lib\site-packages (from beautifulsoup4->wikipedia) (2.2)
Building wheels for collected packages: wikipedia
  Building wheel for wikipedia (setup.py): started
  Building wheel for wikipedia (setup.py): finished with status 'done'
  Created wheel for wikipedia: filename=wikipedia-1.4.0-py3-none-any.whl size=11682 sha256=8a86a8c4df3d17c4591ecb4c2b6f6647e3431f50789b6112d33177624edd574c
  Stored in directory: c:\users\amroldan\appdata\local\pip\cache\wheels\c2\46\f4\caa1bee71096d7b0cdca2f2a2af45cacf35c5760bee8f00948
Successfully built wikipedia
Installing collected packages: wikipedia
Successfully installed wikipedia-1.4.0
[notice] A new release of pip is available: 24.2 -> 24.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip
In [1]:
"""
 / ___|___   __| | ___| | | |_   _ _ __ | |_ ___ _ __ ___  | |    __ _| |__
| |   / _ \ / _` |/ _ \ |_| | | | | '_ \| __/ _ \ '__/ __| | |   / _` | '_ \
| |__| (_) | (_| |  __/  _  | |_| | | | | ||  __/ |  \__ \ | |__| (_| | |_) |
 \____\___/ \__,_|\___|_| |_|\__,_|_| |_|\__\___|_|  |___/ |_____\__,_|_.__/
"""

from PyQt5.QtWidgets import QApplication
import sys

sys.path.insert(0, "../")

from CuriElements.curiwidget import CuriWidget


def app():
    app = QApplication(sys.argv)
    app.setApplicationName('CuriElements')
    app.setApplicationDisplayName('CuriElements')
    app.setOrganizationName('CodeHuntersLab')
    app.setOrganizationDomain('CodeHuntersLab.com')
    app.setApplicationVersion('1.0')
    w = CuriWidget()
    w.show()
    sys.exit(app.exec_())


if __name__ == '__main__':
    app()
Rubidio
El rubidio es un elemento químico de la tabla periódica cuyo símbolo es el Rb y su número atómico es 37.
El rubidio es un metal muy blando y de color blanco plateado del grupo de los metales alcalinos.
finish
play
Sodio
El sodio es un elemento químico de símbolo Na  con número atómico 11 que fue descubierto   en 1807. Es un metal alcalino blando, untuoso, de color plateado, muy abundante en la naturaleza, encontrándose en la sal marina.
finish
play
An exception has occurred, use %tb to see the full traceback.

SystemExit: 0
D:\SW\Programacion\Python\WPy64-3920\python-3.9.2.amd64\lib\site-packages\IPython\core\interactiveshell.py:3445: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
  warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)

image.png

In [ ]:
jupyter nbconvert --to FORMAT notebook.ipynb --to html --template classic --embed-images