【问题标题】:iframe not rendering in ipython-notebookiframe 未在 ipython-notebook 中呈现
【发布时间】:2013-07-12 16:48:54
【问题描述】:

以下 iframe 不会在 ipython-notebook 中呈现

from IPython.display import HTML
HTML('<iframe src=http://stackoverflow.com width=700 height=350></iframe>')

但是,这个会渲染(注意,.com 与 .org)

from IPython.display import HTML
HTML('<iframe src=http://stackoverflow.org width=700 height=350></iframe>')

在第一个示例中我做错了什么吗?如果这是一个错误,我应该在哪里提交错误报告?

【问题讨论】:

  • 也许使用 IPython 显示中的 IFrame 对象会起作用...

标签: python iframe ipython ipython-notebook


【解决方案1】:

IPython 现在直接支持 IFrame:

from IPython.display import IFrame
IFrame('http://stackoverflow.org', width=700, height=350)

有关 IPython 嵌入的更多信息,请查看IPython notebook.

【讨论】:

  • 链接here 与最初链接的链接相似。
【解决方案2】:

您有一个“拒绝显示文档,因为 X-Frame-Options 禁止显示。”在javascript控制台中。一些网站明确拒绝在 iframe 中显示。

【讨论】:

    【解决方案3】:

    通过修改 url 以使用 https,我能够将一些 iframe 嵌入到我的笔记本服务器上:

    from IPython.display import VimeoVideo
    v = VimeoVideo(id='53051817', width=800, height=600)
    print v.src
    >>> 'http://player.vimeo.com/video/53051817'
    v.src = v.src.replace('http','https')
    v
    

    【讨论】:

      【解决方案4】:

      使用%%html魔法单元命令:

      %%html
      <iframe width="700" height="500" src="https://www.youtube.com/embed/r0Ogt-q956I" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
      

      【讨论】:

        猜你喜欢
        • 2017-03-10
        • 2018-05-31
        • 2015-09-23
        • 1970-01-01
        • 2020-05-15
        • 2019-12-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多