'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



Solution 1:[1]

You can try this:

%%html
<iframe src="https://playground.tensorflow.org" width="1200" height="1000"></iframe>

Solution 2:[2]

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")

Solution 3:[3]

You probably meant to use classname rather than the :active CSS pseudo-class.

The line where you have

.navbar-links:active {

Replace : to . as followed:

.navbar-links.active {

and it should work.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 NRR
Solution 2 Ivan Ferrier
Solution 3 John