Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed a website within ipython notebook

I want to make my notebook such that a website open within notebook and anything I do/click in website, it works like it open in new tab but remains within ipython notebook cell only. I know about selenium package which open the website in new tab or there are other ways to0 but every time, I need to leave notebook and go to either new window/tab. So how can I make my ipython notebook such that it open website within cell and whatever I do, it remains within notebook. Thanks

like image 722
Lot_to_learn Avatar asked Oct 24 '18 13:10

Lot_to_learn


2 Answers

You can try this:

%%html
<iframe src="https://playground.tensorflow.org" width="1200" height="1000"></iframe>
like image 78
NRR Avatar answered Nov 15 '22 22:11

NRR


For sites that can be embedded in IFrame, you can try

from IPython.display import IFrame
IFrame("https://www.openasapp.com/embedding-an-iframe-step-by-step/", 900,500)

This will work if IFrame() is the last thing called in the cell becuase Jupyter Notebooks automatically call the display function on the last active line in the cell. If you want to have this at the beginning of the cell, you will need to call display manually like this

from IPython.display import IFrame
display(IFrame("https://www.openasapp.com/embedding-an-iframe-step-by-step/", 900,500))

print("This code is now the last line, so we need to call display(Iframe()) explicitly")
like image 1
Ivan Ferrier Avatar answered Nov 15 '22 22:11

Ivan Ferrier