I am having trouble extracting the option dates from the dropdown menu from the following url"
url = 'https://finance.yahoo.com/quote/AAPL/options'
I have tried to locate proper tags via BeautifulSoup
but it seems to be rendered using Javascript?
I tried looking at network
tab to see if there is some json data that is being utilized to populate the menu. I couldn't figure it out. Am I forced to use something selenium in this case?
Selenium is heavyweight and slow.
Here is what I am attempting:
url = 'https://finance.yahoo.com/quote/AAPL/options?p=AAPL'
response = requests.get(url)
with open('testing.html', 'wb') as f:
f.write(response.content)
soup = BeautifulSoup(response.content, 'html.parser')
Trying to capture various elements, but I can't seem to capture the option data
print(soup.find('div', {"class": "Cf Pt(18px) controls"}))
print(soup.find('select'))
dates =soup.find('div', class_ = "Fl(start) Pend(18px) option-contract-control drop-down-selector")
print(dates)
However I am mostly returning None
. After saving the html
to a file and opening it, it seems
the option dropdown menu is missing, so it seems most likely I am unable to capture the javascript
portion.