【问题标题】:Get iframe content in python在python中获取iframe内容
【发布时间】:2011-01-09 20:20:40
【问题描述】:

我需要 html 页面的内容,但如果 html 页面包含 iframe 元素,我也需要 iframe 内容。 (在 Python 中) 是否可以使用 python 函数加载所有内容?

【问题讨论】:

标签: python iframe


【解决方案1】:

尝试使用BeautifulSoup,其中supports iframes out of the box

代码 sn-p (full code here):

import re
from BeautifulSoup import BeautifulSoup, Comment
...
for iframe in mosoup("iframe"):
    mosoup.iframe.extract()

更新:链接到代码的当前位置(现在在 github 中)。

【讨论】:

  • 忽略它,只需使用 BeautifulSoup 部分并根据您的需要进行调整。
  • 确实很奇怪,我当时链接到了一个有效的源代码sn-p。会尝试找到它。
  • 哇哇哇!我喜欢你所说的“支持开箱即用的 iframe”。我被卖了!
猜你喜欢
  • 2018-10-30
  • 2015-10-28
  • 2012-02-23
  • 2017-03-02
  • 2019-06-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多