Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ from datetime import datetime, timedelta
|
|
| 5 |
import mibian
|
| 6 |
from yahoofinancials import YahooFinancials
|
| 7 |
import matplotlib.pyplot as plt
|
| 8 |
-
|
| 9 |
from selenium.webdriver.common.by import By
|
| 10 |
import chromedriver_autoinstaller
|
| 11 |
|
|
@@ -48,9 +48,11 @@ def main():
|
|
| 48 |
risk_free_rate = round(yahoo_financials_treasuries.get_current_price()/100, 4)
|
| 49 |
st.write(f"Risk-free rate: {risk_free_rate}")
|
| 50 |
|
| 51 |
-
# Set up Selenium
|
| 52 |
url = f"https://finance.yahoo.com/quote/{stock}/options/?straddle=false"
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
driver.get(url)
|
| 55 |
|
| 56 |
experations_btn = driver.find_element(By.XPATH, '/html/body/div[1]/main/section/section/section/article/section[2]/div/div[1]/button').click()
|
|
|
|
| 5 |
import mibian
|
| 6 |
from yahoofinancials import YahooFinancials
|
| 7 |
import matplotlib.pyplot as plt
|
| 8 |
+
import undetected_chromedriver as uc
|
| 9 |
from selenium.webdriver.common.by import By
|
| 10 |
import chromedriver_autoinstaller
|
| 11 |
|
|
|
|
| 48 |
risk_free_rate = round(yahoo_financials_treasuries.get_current_price()/100, 4)
|
| 49 |
st.write(f"Risk-free rate: {risk_free_rate}")
|
| 50 |
|
| 51 |
+
# Set up Selenium with undetected-chromedriver
|
| 52 |
url = f"https://finance.yahoo.com/quote/{stock}/options/?straddle=false"
|
| 53 |
+
options = uc.ChromeOptions()
|
| 54 |
+
options.add_argument('--headless')
|
| 55 |
+
driver = uc.Chrome(options=options)
|
| 56 |
driver.get(url)
|
| 57 |
|
| 58 |
experations_btn = driver.find_element(By.XPATH, '/html/body/div[1]/main/section/section/section/article/section[2]/div/div[1]/button').click()
|