在页面上找不到href

2024-10-03 00:19:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试从该页面查找预告片视频的urlhttps://www.binged.com/streaming-premiere-dates/black-monday/

我检查了div class="wordkeeper-video"的各种属性,找不到它。有人能帮忙吗

enter image description here


Tags: divcom视频www页面classblackdates
3条回答

视频href最初不在那里。 您需要首先单击播放按钮(实际上是图像),然后href显示在那里的iframe中。
{}是{} 因此,您必须切换到iframe,然后提取它的src属性

完整的URL不在那里,但您只需要构建它

<div class="wordkeeper-video " data-type="youtube" data-embed="pzxGR6Q-7Mc" ...>

data-embed属性具有您需要的功能

网址是

https://www.youtube.com/watch?v=pzxGR6Q-7Mc
                                ^ here's the data-embed value

你可以通过使用

data_embed = driver.find_element_by_css_selector(".wordkeeper-video").get_attribute("data-embed")
video_url = "https://www.youtube.com/watch?v=" + data_embed

去玩吧。然后会有这样的事情。链接位于src标记中

<iframe frameborder="0" allowfullscreen="" allow="autoplay" src="https://www.youtube.com/embed/pzxGR6Q-7Mc?rel=0&amp;showinfo=0&amp;autoplay=1"></iframe>

PS:它在div class="wordkeeper-video"

相关问题 更多 >