我想要获取此页上的视频链接https://in.news.yahoo.com/video/jitendra-singh-visits-manipur-militants-051500244.html。我尝试了多种方式使用硒,但没有运气。有人能指出我在做什么镀铬错使用硒从视频标签获取src
driver = webdriver.Chrome()
def getVideoTrend(self, "https://in.news.yahoo.com/video/jitendra-singh-visits-manipur-militants-051500244.html"):
driver.get(url)
element = WebDriverWait(driver, 10).until(lambda driver: driver.find_elements_by_class_name('mediavideoplayervppca'))
video_trend = []
#s = driver.find_element_by_css_selector('video.yvp-html5-video') #this also does not help
s = driver.find_elements_by_xpath('//*[@id="yui_3_9_1_1_1434089562443_964"]')
print s
print s.get_attribute('src')
请打开链接以查看页面元素
的该元素的ID总是在变化,所以你将无法得到它。只需刷新页面并再次检查元素,它将具有不同的ID。另一方面,视频将在Flash Applet中播放,并且不包含视频的来源。 – peetya
@peety:如果你看到的是Chrome浏览器,你可以看到视频标签和url,id值会改变,但 – nlper
页面上没有'video'标签,这是一个flash player对象。 – alecxe