小篇去參考https://www.cnblogs.com/101718qiong/p/7472826.html 
要在html5播網路上面的影片
無奈......
 driver.execute_script("return arguments[0].play()",video)  和 driver.execute_script("return arguments[0].pause()",video) 

都失效了,那只能改寫改用滑鼠自己點擊]

code 如下

 

from  selenium import  webdriver
import time
from  selenium.webdriver.common.action_chains import ActionChains

chrome_path = ".\chromedriver.exe" #chromedriver.exe執行檔所存在的路徑
driver = webdriver.Chrome(chrome_path)

driver.get("https://videojs.com/")

video=driver.find_element_by_xpath('//*[@id="preview-player_html5_api"]')

#video=driver.find_element_by_xpath('/html/body/video')
print(video)
url=driver.execute_script("return arguments[0].currentSrc;",video)

print(url)


videoDuration=driver.execute_script("return arguments[0].duration;",video)
print("videoDuration",videoDuration)

print("start")
ActionChains(driver).move_to_element(video).perform()
ActionChains(driver).click(video).perform()
#driver.find_element_by_xpath('//*[@id="preview-player_html5_api"]').click()

time.sleep(15)
print("stop")
ActionChains(driver).move_to_element(video).perform()
ActionChains(driver).click(video).perform()
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 qqo9110 的頭像
    qqo9110

    阿藏哥的部落格~不應該阿

    qqo9110 發表在 痞客邦 留言(0) 人氣()