Last active
February 12, 2023 13:30
-
-
Save rudensm/f1bb27b6524f246fc946cc588416cc73 to your computer and use it in GitHub Desktop.
Python Selenium Yahoo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from seleniumwire import webdriver | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support import expected_conditions as EC | |
from selenium.webdriver.support.ui import WebDriverWait | |
# open browser; | |
options = webdriver.ChromeOptions() | |
options.add_argument("--window-size=1920,2000") | |
driver = webdriver.Chrome(chrome_options=options) | |
# load website; | |
driver.set_page_load_timeout(30) | |
driver.get("https://yahoo.com/") | |
# wait for necessary element; | |
wait = WebDriverWait(driver, 30) | |
element = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".consent-form [type=submit]"))) | |
# perform; | |
element.click() | |
# close browser; | |
driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment