如何在python中用selenium读取这个src文本?

时间:2016-04-20 16:56:24

标签: python selenium

<iframe id="frameNewAnimeuploads0" src="http://www.watchcartoononline.com/inc/animeuploads/embed.php?file=rick%20and%20morty%2FRick.and.Morty.S02E10.The.Wedding.Squanchers.720p.WEB-DL.DD5.1.flv&amp;hd=1" width="530" height="410" frameborder="0" scrolling="no" allowfullscreen=""></iframe>

我想阅读src文本。 (http://www.watchcartoononline.com/inc/animeuploads/embed.php?file=rick%20and%20morty%2FRick.and.Morty.S02E10.The.Wedding.Squanchers.720p.WEB-DL.DD5.1.flv&hd=1

我怎么读这个?

1 个答案:

答案 0 :(得分:1)

这就是你如何做到的。您需要确定frame WebElement,然后使用getAttribute方法获取Attribute

frame = driver.find_element_by_id('frameNewAnimeuploads0')
frame.get_attribute("src")

希望它有所帮助!