Mimicking HTML5 Video Support on PhantomJS Used Through Selenium in Python

I am trying to extract the source link of an HTML5 video found in a video tag. Using Firefox webdrive, I can get the desired result, i.e. -

[<video class="video-stream html5-main-video" src='myvideoURL..'</video>]

but if I use PhantomJS -

 <video class="video-stream html5-main-video" style="width: 854px; height: 480px; left: 0px; top: 0px; -webkit-transform: none;" tabindex="-1"></video>

I suspect this is due to the lack of PhantomJS support for HTML5 video support. Anyway, can I fool a webpage into thinking that HTML5 Video is supported so that it generates a URL? Or can I do something else?

tried it

try:

    WebDriverWait(browser,10).until(EC.presence_of_element_located((By.XPATH, "//video")))


finally:


    k = browser.page_source


    browser.quit()


soup = BeautifulSoup(k,'html.parser')


print (soup.find_all('video'))
+4
source share
1 answer

The way Firefox and phantomjs webdrivers communicate with Selenium is completely different.

Firefox , javascript

, phantomjs Selenium , , , javascript.

, , , :

video = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//video")))

EDIT:

Youtube , , , , ,

+2

Source: https://habr.com/ru/post/1653527/


All Articles