python beautifulsoup iframe文档html提取(python beautifulsoup iframe document html extract)
我正在尝试学习一些美丽的汤,并从一些iFrames中获取一些html数据 - 但迄今为止我还没有取得非常成功。
所以,解析iFrame本身似乎并不是BS4的问题,但我似乎并没有从中获得嵌入的内容 - 无论我做什么。
例如,考虑下面的iFrame(这是我在Chrome开发人员工具上看到的):
<iframe frameborder="0" marginwidth="0" marginheight="0" scrolling="NO" src="http://www.engineeringmaterials.com/boron/728x90.html "width="728" height="90"> #document <html>....</html></iframe>
其中,
<html>...</html>
是我有兴趣提取的内容。但是,当我使用以下BS4代码时:
iFrames=[] # qucik bs4 example for iframe in soup("iframe"): iFrames.append(soup.iframe.extract())
我得到:
<iframe frameborder="0" marginwidth="0" marginheight="0" scrolling="NO" src="http://www.engineeringmaterials.com/boron/728x90.html" width="728" height="90">
换句话说,我得到了其中没有文档
<html>...</html>
的iFrame。我尝试了以下几点:
iFrames=[] # qucik bs4 example iframexx = soup.find_all('iframe') for iframe in iframexx: print iframe.find_all('html')
..但这似乎并没有工作..
所以,我想我的问题是,我如何可靠地从iFrame元素中提取这些文档对象
<html>...</html>
。I am trying to learn a bit of beautiful soup, and to get some html data out of some iFrames - but I have not been very successful so far.
So, parsing the iFrame in itself does not seem to be a problem with BS4, but I do not seem to get the embedded content from this - whatever I do.
For example, consider the below iFrame (this is what I see on chrome developer tools):
<iframe frameborder="0" marginwidth="0" marginheight="0" scrolling="NO" src="http://www.engineeringmaterials.com/boron/728x90.html "width="728" height="90"> #document <html>....</html></iframe>
where,
<html>...</html>
is the content I am interested in extracting.However, when I use the following BS4 code:
iFrames=[] # qucik bs4 example for iframe in soup("iframe"): iFrames.append(soup.iframe.extract())
I get:
<iframe frameborder="0" marginwidth="0" marginheight="0" scrolling="NO" src="http://www.engineeringmaterials.com/boron/728x90.html" width="728" height="90">
In other words, I get the iFrames without the document
<html>...</html>
within them.I tried something along the lines of:
iFrames=[] # qucik bs4 example iframexx = soup.find_all('iframe') for iframe in iframexx: print iframe.find_all('html')
.. but this does not seem to work..
So, I guess my question is, how do I reliably extract these document objects
<html>...</html>
from the iFrame elements.
原文:https://stackoverflow.com/questions/23028664
最满意答案
可以用 gcc呀
相关问答
更多-
电脑应用专业出来找什么工作啊?[2023-05-22]
编程 -
信息与电脑科学是学什么的?[2022-11-19]
编程 -
linux 下面怎么配置 java编程环境[2024-01-22]
纯java开发的软件在linux下面也可以应用自如。那么首先就需要配置好linux下的java环境,具体说来,就是配置jdk环境变量。 介绍在linux下配置jdk环境变量的几种常用方法。 首先在linux下安装jdk,如果出现提示权限不够(且root下也提示权限不够),可用#ls -l filename命令查看一下,如果显示类似如: 则表示任何用户都没有可执行权限(即使是root用户)。 解决方法: #chmod a+x filename 这样,安装好后,就可以接下来进行环境变量的配置了。这里给出三种可选 ... -
如何在linux系统安装python编程环境[2022-03-23]
eclipse 是 JAVA 写的,全系统支持。 至于你说的那个 pydev ,我想应该也是解释型语言写的,里面不含二进制程序。都能跨平台。 -
Linux下编程环境的安装[2022-03-04]
1、安装的过程中会提示你选择相应的软件包来安装,是安装好了的。另外你说的编程环境指的是哪种语言的编程环境?是不是带ui的? 2、没有你说的那种成套的。视频是需要自己找驱动的,QQ也只有QQ for linux(已经不维护了),linux有自己的聊天工具(iptux,pidgin等等)。对于解压缩软件,如果不是解压rar、zip等windows下的压缩格式的话,linux有自己的压缩格式和解压命令,都是自带的。如果要解压windows下的压缩文件,可以安装rar for linux。对于杀毒,linux有很高 ... -
怎样在linux下编程,怎么进入编程环境?[2023-12-15]
Linux默认不安装任何编程环境的,图形桌面下的IDE功能也并不是多完善:Linux下最常见的是“开发套件”(真正搞开发的没几个愿意在图形环境的IDE中干活,所以较之于IDE环境,开发套件更合适,这点跟Windows不同)。 安装好开发套件(如gcc),就可以在任何时候从文本控制台调用它的任何命令,而不是先运行一个巨大的编程环境。 -
linux的编程环境[2021-09-19]
1启动快,不用听硬盘嘎拉嘎拉嘎拉的。 2VIM看代码比较好,不在编辑状态下改不了代码,避免不小心下的误操作;IDE还要启X,linux很多时候要用命令行解决问题,切来切去麻烦;用多了就很习惯,vim红红绿绿的我觉得很好看。 3当然,vim功能很强大,不用多说,比那些免费的IDE要好用。IDE只是提供了一个操作界面,很多IDE都不完善有bug。 4底层编程,用不着IDE,比如即便是微软,写STL等底层库的时候也使用VIM的,你去看一下VC的STL源码,就会发现,那种对齐的风格根本就不是VS的。 Linux下用 ... -
Linux环境下编程[2023-07-11]
干这个活还是用 FEDORA 或 GENTOO 好一些 -
最新开通快手实验室教程 直播权限?[2022-02-22]
简单 -
Linux环境下的简单编程[2022-07-12]
可以用 gcc呀