I want to extract the SMR rating from this website:
Url: Apple Inc Stock Quote: AAPL Stock News, Quotes, Analysis | Investors.com
My problem is that I can't seem to find the correct location even if I just use one URL without any variations.
If I introduce stock name variations, I can't do it via URL manipulation, as each ticker has a unique URL that is not simply created by inserting a new ticker name. Few examples:
NVDA:
https://research.investors.com/stock-quotes/nasdaq-nvidia-corp-nvda.htm
AMZN:
https://research.investors.com/stock-quotes/nasdaq-amazoncom-inc-amzn.htm
As you can see, the URLs are vastly different. Does that mean that I'd have to find a hidden API to get access to the SMR rating?
Here's my current python code:
import pandas as pd
import requests
from bs4 import BeautifulSoup
import re
url = 'Apple Inc Stock Quote: AAPL Stock News, Quotes, Analysis | Investors.com'
req = Request(url, headers={'User-Agent': 'Mozilla/5.0'})
website = urlopen(req).read()
html = soup(website, 'html.parser')
print(html)
fundamentals = pd.read_html(str(html), attrs = {'class': 'smartContent'})[0]
The class of the table is smartContent and the individual entries are stored in unordered javascript lists.
Yet, when I run that code, it tells me that no table is found.
What should I do?
Sitemap:
{id:"sitemap code"}