Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outputing HTML Ipython object to disk

How can I output an IPython HTML object of the form <IPython.core.display.HTML object> to a HTML file or PDF file on disk?

like image 598
user308827 Avatar asked Dec 25 '16 04:12

user308827


1 Answers

You can do something like this:

from IPython.core.display import HTML

a = HTML('<a href="http://example.com">LINK TO THE WEB PAGE</a>')
html = a.data
with open('html_file.html', 'w') as f:
    f.write(html)
like image 177
Mohammad Yusuf Avatar answered Sep 18 '22 11:09

Mohammad Yusuf