Where can I found on https://spglobal.com S&P 500
index actual official stock weights.
1 Answer
I found one source that has the data as an html table.
https://www.slickcharts.com/sp500
You can use pandas to parse the html table as a dataframe, and then write a csv:
import pandas as pd
import requests
df = pd.read_html(requests.get('https://www.slickcharts.com/sp500',
headers={'User-agent': 'Mozilla/5.0'}).text)[0]
print(df)
df.to_csv('sp.csv',index=False)
And here's the data as of 2021-05-06
https://gist.github.com/philshem/f2fc94d7e49f045fe0feda8532ab2c08#file-sp-csv
-
I know about slickchart, but I search official information. Thanks anyway for the answer.– VitaliiCommented May 7, 2021 at 13:58