|
# Adding adblocker extension |
|
options = Options() |
|
|
|
options.add_extension( |
|
"/Users/marcosantos/Downloads/extension_1_37_2_0.crx" |
|
) |
|
|
|
# Opening the browser |
|
driver = webdriver.Chrome( |
|
executable_path="/Users/marcosantos/Downloads/chromedriver", |
|
options=options |
|
) |
|
|
|
# Designating which site to open to |
|
driver.get("https://www.google.com") |
|
|
|
# Typing into search and hitting enter |
|
WebDriverWait(driver, 3).until( |
|
EC.element_to_be_clickable( |
|
(By.XPATH, "//input[@class='gLFyf gsfi']") |
|
)).send_keys("yahoo finance", Keys.ENTER) |
|
|
|
# Clicking on the desired result |
|
WebDriverWait(driver, 3).until( |
|
EC.element_to_be_clickable( |
|
(By.XPATH, "//div[@class='tF2Cxc']") |
|
)).click() |
|
|
|
# Searching a Ticker |
|
WebDriverWait(driver, 3).until( |
|
EC.element_to_be_clickable( |
|
(By.XPATH, "//input[@id='yfin-usr-qry']") |
|
)).send_keys("AMC", Keys.ENTER) |
|
|
|
# Clicking Historical Data |
|
WebDriverWait(driver, 3).until( |
|
EC.element_to_be_clickable( |
|
(By.XPATH, "//li[@data-test='HISTORICAL_DATA']") |
|
)).click() |
|
|
|
# Getting historical date range |
|
WebDriverWait(driver, 3).until( |
|
EC.element_to_be_clickable( |
|
(By.XPATH, |
|
"//*[@id='Col1-1-HistoricalDataTable-Proxy']/section/div[1]/div[1]/div[1]/div/div/div[1]/span") |
|
)).click() |
|
|
|
# Getting max historical range |
|
WebDriverWait(driver, 3).until( |
|
EC.element_to_be_clickable( |
|
(By.XPATH, "//*[@id='dropdown-menu']/div/ul[2]/li[4]/button") |
|
)).click() |
|
|
|
# Applying the changes |
|
WebDriverWait(driver, 3).until( |
|
EC.element_to_be_clickable( |
|
(By.XPATH, |
|
"//*[@id='Col1-1-HistoricalDataTable-Proxy']/section/div[1]/div[1]/button/span") |
|
)).click() |
|
|
|
# Downloading the file |
|
WebDriverWait(driver, 3).until( |
|
EC.element_to_be_clickable( |
|
(By.XPATH, |
|
"//*[@id='Col1-1-HistoricalDataTable-Proxy']/section/div[1]/div[2]/span[2]/a/span") |
|
)).click() |
|
|
|
# Closing the window but allowing some time for download |
|
time.sleep(1) |
|
driver.quit() |