Here's the code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
drive = "******/chromedriver"
driver = webdriver.Chrome(executable_path=drive)
print(driver.execute_script("return navigator.userAgent;"))
driver.get("https://twitter.com/login")
time.sleep(3)
username = driver.find_element_by_name("session[username_or_email]")
username.send_keys('******@****.com')
time.sleep(3)
password = driver.find_element_by_name('session[password]')
time.sleep(3)
password.send_keys('*******')
password.send_keys(Keys.RETURN)
time.sleep(3)
driver.get("https://twitter.com/********/media")
time.sleep(3)
videos = driver.find_elements_by_xpath('//video[@preload="auto"]')
sources = [video.get_attribute('src') for video in videos]
print(sources)
scroll_page = driver.execute_script('return document.body.scrollHeight')
But when I repeat the "sources" and "scroll_page" I get the error: selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
I am only getting the first 7 url src from video tag even if the page has been scrolled to the next.
My apology if there are some prohibited in this code or the target site or the this website rules.
Many thanks in advance for the help guys!