使用Python的BeautifulSoup提取iFrame

使用Python的BeautifulSoup提取iFrame,python,beautifulsoup,canvas-lms,Python,Beautifulsoup,Canvas Lms,我使用Canvas LMS,我想从一些页面中提取iframe来更改src内容。 我尝试以下方法: //some code soup = BeautifulSoup(page_html, 'html.parser') pretty_html = soup.prettify() soup = BeautifulSoup(pretty_html, 'html.parser') iframe = soup.find('iframe') print(iframe) 但结果出乎意料,我得到了这个结果: N

我使用Canvas LMS,我想从一些页面中提取iframe来更改src内容。 我尝试以下方法:

//some code
soup = BeautifulSoup(page_html, 'html.parser')
pretty_html = soup.prettify()
soup = BeautifulSoup(pretty_html, 'html.parser')
iframe = soup.find('iframe')
print(iframe)
但结果出乎意料,我得到了这个结果:

None
None
<iframe allowfullscreen="" frameborder="0" height="276" mozallowfullscreen="" scrolling="no" src="https://fast.player.liquidplatform.com/pApiv2/embed/e50a2b66dc19adc532f288eb4bf2d302/%20f2c5f6ca3a4610c55d70cb211ef9d977" webkitallowfullscreen="" width="490"></iframe>
None
None
None
None
None
None
无
没有一个
没有一个
没有一个
没有一个
没有一个
没有一个
没有一个
我只想得到这个

<iframe allowfullscreen="" frameborder="0" height="276" mozallowfullscreen="" scrolling="no" src="https://fast.player.liquidplatform.com/pApiv2/embed/e50a2b66dc19adc532f288eb4bf2d302/%20f2c5f6ca3a4610c55d70cb211ef9d977" webkitallowfullscreen="" width="490"></iframe>


收到的html页面只有一个iframe,结果有什么问题?我想我应该只收到一个iframe对象,但似乎我收到了一个列表。有人可以帮我澄清我做错了什么?

我发现了如何解决问题

我更改代码:

iframe = soup.find('iframe')

然后,我开始收到[],而不是没有收到任何回复。空值

我使用以下方法对其进行了测试:

if iframes != [] :
    print( iframes[0]['src'] )
我使用iframes[0]['src']获得了src的内容

if iframes != [] :
    print( iframes[0]['src'] )