You could use a Selenium WebDriver to load the page, WebElement containing the download button and click() it but that would be a slow and brittle solution compared to calling the API directly.
My approach to this problem would be to reverse engineer the Yahoo Finance URL and fetch the data with the Requests library. The result is a CSV with the historical data that you're looking for.
If you look at the download URL... the URL query parameters are fairly intuitive to understand.
https://query1.finance.yahoo.com/v7/finance/download/ETH-USD?period1=1581795382&period2=1613417782&interval=1d&events=history&includeAdjustedClose=true
We can see that the key components to modify are the stock ticker, date range, and interval. In code...
import csv
from datetime import datetime, timedelta
from io import StringIO
import requests
ticker = 'ETH-USD'
url = f'https://query1.finance.yahoo.com/v7/finance/download/{ticker}'
now = datetime.now()
start_ts = int((now - timedelta(days=365)).timestamp())
end_ts = int(now.timestamp())
params = {
'period1': start_ts,
'period2': end_ts,
'interval': '1d',
'events': 'history',
'includeAdjustedClose': True,
}
result = requests.get(url, params=params)
f = StringIO(result.content.decode('utf-8'))
reader = csv.reader(f, delimiter=',')
for row in reader:
print('\t'.join(row))