user308827
user308827

Reputation: 22021

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?

Upvotes: 6

Views: 9825

Answers (1)

Mohammad Yusuf
Mohammad Yusuf

Reputation: 17074

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)

Upvotes: 11

Related Questions