from html to jupyter notebook

Solutions on MaxInterview for from html to jupyter notebook by the best coders in the world

showing results for - "from html to jupyter notebook"
Constance
09 Sep 2018
1from bs4 import BeautifulSoup
2import json
3import urllib.request
4url = 'http://nbviewer.jupyter.org/url/jakevdp.github.com/downloads/notebooks/XKCD_plots.ipynb'
5response = urllib.request.urlopen(url)
6#  for local html file
7# response = open("/Users/note/jupyter/notebook.html")
8text = response.read()
9
10soup = BeautifulSoup(text, 'lxml')
11# see some of the html
12print(soup.div)
13dictionary = {'nbformat': 4, 'nbformat_minor': 1, 'cells': [], 'metadata': {}}
14for d in soup.findAll("div"):
15    if 'class' in d.attrs.keys():
16        for clas in d.attrs["class"]:
17            if clas in ["text_cell_render", "input_area"]:
18                # code cell
19                if clas == "input_area":
20                    cell = {}
21                    cell['metadata'] = {}
22                    cell['outputs'] = []
23                    cell['source'] = [d.get_text()]
24                    cell['execution_count'] = None
25                    cell['cell_type'] = 'code'
26                    dictionary['cells'].append(cell)
27
28                else:
29                    cell = {}
30                    cell['metadata'] = {}
31
32                    cell['source'] = [d.decode_contents()]
33                    cell['cell_type'] = 'markdown'
34                    dictionary['cells'].append(cell)
35open('notebook.ipynb', 'w').write(json.dumps(dictionary))
36
Noémie
08 Sep 2020
1from IPython.display import HTML
2HTML(filename='myhtml.html')
3
queries leading to this page
jupyter notebook html linkhow to open html file in jupyter notebookhow to save jupyter notebook as htmlimport html file into jupyterknit to html jupyter notebookhow to i load an html file link into a jupyter notebookview html code jupyter notebookhow to write html code in jupyter notebookimport html file in jupyter notebookoutput jupyter notebook as htmlopen html file jupyter notebookjupyter notebook htmlconvert jupyter notebook to htmlconverting jupyter notebook files to htmlsave jupyter notebook as htmlconvert jupyter notebook to interactive htmlhow to use html in jupyter notebookhow do i import an html file into a jupyter notebook 3fcan you do html in jupyterhtml jupyter notebookcan we write html code in jupyter notebook 3fhow to code html on jupyter notebookhtml in jupyter notebookconvert html to jupyter notebookdisplay 28html file in jupyter notebook 29show jupyter notebook htmljupyter notebook output html without coderun html file in jupyter notebookcan you use html in jupyter notebook 3fconvert jupyter notebook to html from notebookdisplay html in jupyter notebookopen html file in jupyter notebooksave a jupyter notebook as htmlhow to output jupyter notebook as htmljupyter notebook python code in htmlhtml output jupyter notebookload html code in jupyter notebookhtml code in jupyter notebookhow to read import a html file to jupiter notebookexport jupyter notebook to htmlimport html into jupyter notebookshow html in jupyter notebookwhat is html file of jupyter notebookgenerate thinner html from jupyter notebookdisplay html file in jupyter notebook 29jupyter notebook create htmlfrom html to jupyter notebookhow to run html code in jupyter notebookdisplay html file in jupyter notebookjupyter notebook to htmlimport the output of the jupyter notebook to htmljupyter notebook to html converterconvert jupyter notebook to html without codehow to display html in jupyter notebookfrom html to jupyter notebook