Мой код:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
import time
name = 'hello world'
driver = webdriver.Firefox()
driver.get('https://www.youtube.com')
id_serth = driver.find_element(By.NAME, "search_query")
id_serth.send_keys(name)
button_serth = driver.find_element(By.ID, "search-icon-legacy")
time.sleep(1)
button_serth.click()
time.sleep(3)
button_filtr = driver.find_element(By.CLASS_NAME ,"ytd-toggle-button-renderer")
button_filtr.click()
time.sleep(3)
button_filtrtode=driver.find_element(By.CLASS_NAME, "ytd-search-filter-renderer")
button_filtrtode.click()
#linkvideo2 = driver.find_element(By.ID, "video-title").get_attribute("href")
time.sleep(3)
urltek = driver.current_url
linkvideo2 = driver.find_element(By.XPATH, '//*[@id="video-title"]').get_attribute('href')
print (linkvideo2)
print (urltek)
Получаю ответ None
p.s только не давно начал изучать selenium не бейте)
Ответ :
None
https://www.youtube.com/results?search_query=hello+world&sp=EgIIAQ%253D%253D