Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t使用beautifulSoup python从iframe获取src_Python_Python 3.x_Beautifulsoup_Python Requests - Fatal编程技术网

Can';t使用beautifulSoup python从iframe获取src

Can';t使用beautifulSoup python从iframe获取src,python,python-3.x,beautifulsoup,python-requests,Python,Python 3.x,Beautifulsoup,Python Requests,我试图用python中的BeautifulSoup从网页中提取视频,但遇到了一些问题 当我进入网页查看html元素时,我看到了这个标签 <iframe id="iframe-embed2" src="https://player.voxzer.org/view/1167612b04f6855ecc4bb5e0" allowfullscreen="true" webkitallowfullscreen="true"

我试图用python中的BeautifulSoup从网页中提取视频,但遇到了一些问题

当我进入网页查看html元素时,我看到了这个标签

<iframe id="iframe-embed2" src="https://player.voxzer.org/view/1167612b04f6855ecc4bb5e0" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" width="100%" height="auto" frameborder="0"></iframe>

当我复制src并打开它时,它会显示视频

但是当我使用BeautifulSoup从网页中查找iframe时,我得到的src是空字符串

导入请求
从bs4导入BeautifulSoup
site=requests.get(“url…”)
soup=BeautifulSoup(site.text,“html.parser”)
打印(soup.find_all(“iframe”))
>>> []
这里有什么问题

这个问题没有任何有效的解决办法

这里有什么问题

我查看了
站点。text
发现
https://player.voxzer.org/view/1167612b04f6855ecc4bb5e0
要放置在一行中

mainvideos.push('https://player.voxzer.org/view/1167612b04f6855ecc4bb5e0')

由于
.push
是JavaScript方法,显然这个iframe的
src
是由JavaScript代码设置的,所以你需要一种方法来执行站点的JavaScript代码(例如使用Selenium)。

你能发布网页吗?这使得重现您的问题更容易。@DSteman ok这是网页,请检查您获取的内容中是否设置了
src
,即执行
print('src='https://player.voxzer.org/view/1167612b04f6855ecc4bb5e0“'in site.text)
紧接着
site=requests
。。。行并写下是什么output@Daweo这是真的