Warm tip: This article is reproduced from serverfault.com, please click

scraping youtube with selenium python

发布于 2020-06-19 08:02:33

I want to scrape the first two videos from the youtube search result, I have a list of words in CSV file I want to get the first two videos for each query, I tried to use selenium python but I get the error , so there is any way to do that.

CODE:

search_input = driver.find_element_by_css_selector('#search').send_keys('')

ERROR:

selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
Questioner
Eslam Tantawy
Viewed
0
frianH 2020-06-19 16:26:55

There are more than one element when using your selector #search.

.find_element_by_* refers to the first element, sadly the input element you are referring to is not the first. The first element with your selector is a hidden element, that's what causes you to get the .....element not interactable error.

A unique locator for that is input#search:

driver.find_element_by_css_selector('input#search').send_keys('test')