0

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
2
  • I would rather call youtube.com/results?search_query=<SEARCH-TERM> instead of using search bar. Commented Jun 19, 2020 at 8:09
  • Best way to scrape could be to use its api. Please take a look at it Commented Jun 19, 2020 at 8:58

1 Answer 1

1

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')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.