How To Pull S&P 500 Tickers Using Wikipedia

This is an example of using Python to read a table. In this instance, the code will read all the symbols on a Wikipedia page for the S&P 500.

This code can be part of a larger process. Maybe you need a list of tickers to then run through some filtering program.

GitHub Link

#import libraries
import pandas as pd

#Pull tickers from wikipedia
sp_df = pd.read_html('https://en.wikipedia.org/wiki/List_of_S%26P_500_companies')[0]
tickers_list = list(sp_df['Symbol'])[:]
print(tickers_list)

In addition to using the S&P 500 link you could also use the following with minimal code changes

Sharing

Related Articles

  • All Post
  • Articles
  • Blog Post
  • General Business Automation
  • Portfolio
  • Stock Market & Finance