My goal is to scrape the src link within the video tag on this webpage. This is where I am seeing the video tag along with the link which I want.
- I know how to grab the information within the tag using
driver.find_element(By.XPATH, '//video')
- But when I tried to find the Xpath of the tag by using the console, I was unable to find it.
- I also tried
driver.find_element(By.TAG_NAME, 'video')
but I got<selenium.webdriver.remote.webelement.WebElement (session="6a5b945439665a2261e0bb7cf4a19c8e", element="127606c2-b043-4b55-b8ff-5456bb39a2c3")>
from which I dont know how to get the src link. I tried to use.text
but it became blank. - I tried parsing through the page_source and finding the link manually but I still could'nt find it.
- There is a
= $0
right after the end of the video tag, meaning its a [last selected DOM node index]Selenium Duplicate Elements marked with ==$0 - When I type
$0
orconsole.log($0)
into the console I get the video tag with the link. - What should I do scrape this tag and its contents ?
CodePudding user response:
You can get the source attribute with:
[...]
source = driver.find_element(By.XPATH, '//video').get_attribute('src')
print(source)
[...]
Result in terminal:
blob:https://mplayer.me/d420cb30-ed6e-4772-b169-ed33a5d3ee9f
See Selenium documentation at https://www.selenium.dev/documentation/