I'm trying to scrape all list from URL: https://trends.google.com/trends/yis/2021/ID/ Before I scrape all the items in lists, I want to open all items by clicking all the show more buttons. how can I click all the show more buttons with Selenium and Python?
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
url = "https://trends.google.com/trends/yis/2021/ID/"
driver = webdriver.Firefox()
driver.get(url)
try:
element = WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.CLASS_NAME, "show-more")))
for i in element:
i.click()
except Exception as e:
print(e)
driver.quit()
This code show this error:
Message: Element could not be scrolled into view Stacktrace: WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:181:5 ElementNotInteractableError@chrome://remote/content/shared/webdriver/Errors.jsm:291:5 webdriverClickElement@chrome://remote/content/marionette/interaction.js:156:11 interaction.clickElement@chrome://remote/content/marionette/interaction.js:125:11 clickElement@chrome://remote/content/marionette/actors/MarionetteCommandsChild.jsm:200:24 receiveMessage@chrome://remote/content/marionette/actors/MarionetteCommandsChild.jsm:91:31