I've been trying to get the upload date of a YouTube video (as the following picture shows) with Selenium in Python.
My code is as follows:
! pip install selenium
from selenium import webdriver
! pip install beautifulsoup4
from bs4 import BeautifulSoup
driver = webdriver.Chrome('D:\chromedrive\chromedriver.exe')
driver.get("https://www.youtube.com/watch?v=CoR72I5BGUU")
soup = BeautifulSoup(driver.page_source, 'lxml')
upload_date=driver.find_elements_by_xpath('//*[@id="info-strings"]/yt-formatted-string')
print(upload_date)
However, no matter I used upload_date=soup.findAll('span', class_='style-scope ytd-grid-video-renderer')
or upload_date=driver.find_elements_by_xpath('//*[@id="info-strings"]/yt-formatted-string')
, it didn't work.
If anyone knows where the problem is, please help me.