I would like to extract, for example, all the values that are within the "Holdings" from https://www.morningstar.com/funds/xnas/aepfx/portfolio. Some of these values are:
- Current Portfolio Date = Mar,31 2022
- Equity Holdings = 384
I tried some different approaches but none of them seem to work.
1st) Tried via:
soup.find_all("div", class_="sal-dp-value")
But this will return empty
What is odd for me is that I don't even find
<div class="sal-dp-value">Mar 31, 2022</div>
when searching on the raw data printed by:
import requests
r = requests.get('https://www.morningstar.com/funds/xnas/aepfx/portfolio')
soup = BeautifulSoup(r.text, "html.parser")
soup.html
Not ideally as I prefer to use Beautifulsoup but also tried via Xpath:
import requests
from lxml import html
page = requests.get("https://www.morningstar.com/funds/xnas/aepfx/portfolio").text
holdings = html.fromstring(page).xpath('/html/body/div[2]/div/div/div[2]/div[3]/div/main/div[2]/div/div/div[1]/sal-components/section/div/div/div[3]/sal-components-mip-holdings/div/div/div/div[2]/div[1]/ul/li[1]/div/div[2]')
holdings
Which will return empty.
Ish similar question: