I made a script in python and selenium that makes a search on youtube. When it's completely loaded, I'm only able to fetch all titles from the results. Is there any line of code I can integrate in order to fetch date publishing too?
This is my code:
def youTube():
term = 'bitcoin'
tit = []
d = webdriver.Firefox()
d.get('https://www.youtube.com/results?search_query='+term+'&sp=CAISAhAB')
sleep(3)
d.find_element_by_xpath("//*[contains(text(), 'Accetto')]").click()
sleep(2)
scrollHeight = d.execute_script("return window.scrollMaxY")
print(scrollHeight)
scrolled_pages = 0
# while we have not reached the max scrollHeight
while d.execute_script("return window.pageYOffset") < 3000:
d.execute_script("window.scrollByPages(1)")
scrolled_pages += 1
sleep(0.2)
for my_elem in WebDriverWait(d, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//yt-formatted-string[@class='style-scope ytd-video-renderer' and @aria-label]"))):
tit.append(my_elem.text)