12. News Scraping with Python#

%%capture
#INCLUDING SCIENTIFIC AND NUMERICAL COMPUTING LIBRARIES
#Run this code to make sure that you have all the libraries at one go.
%pylab inline
import os
import pandas as pd
%load_ext rpy2.ipython
# Basic lines of code needed to import a data file with permissions from Google Drive
from google.colab import drive
# drive.mount("/content/drive", force_remount=True)
drive.mount('/content/drive')
os.chdir("drive/My Drive/Books_Writings/NLPBook/")
Mounted at /content/drive

12.1. News Extractor: Reading in parts of a URL#

Let’s read in the top news from the ET main page.

You also want to get SelectorGadget: http://selectorgadget.com/

!pip install cssselect
Collecting cssselect
  Downloading cssselect-1.3.0-py3-none-any.whl.metadata (2.6 kB)
Downloading cssselect-1.3.0-py3-none-any.whl (18 kB)
Installing collected packages: cssselect
Successfully installed cssselect-1.3.0
import requests
from lxml.html import fromstring
# Collect some text data
!pip install cssselect
import requests
from lxml.html import fromstring

#Copy the URL from the web site
url = 'https://economictimes.indiatimes.com'
html = requests.get(url, timeout=10).text

#See: http://infohost.nmt.edu/~shipman/soft/pylxml/web/etree-fromstring.html
doc = fromstring(html)

#http://lxml.de/cssselect.html#the-cssselect-method
x = doc.cssselect(".jsx-48c379259a10063f")
print(len(x))

headlines = [j.text_content() for j in x]
headlines = [j for j in headlines if len(j)>20]
headlines = unique(headlines)
headlines = headlines[:20]   #Needed to exclude any other stuff that was not needed.
for h in headlines:
    print(h)
Requirement already satisfied: cssselect in /usr/local/lib/python3.12/dist-packages (1.3.0)
50
'There will always only be one Jane Goodall'
Daniel Kretinsky to sell Thyssenkrupp stake
EU to increase tariffs on steel imports
Ex-RAW chief calls Pak's Munir a jihadi
Franchise flicks lose their shine
Franchise flicks lose their shineRBI weighs uniform compensation policyDaniel Kretinsky to sell Thyssenkrupp stakePutin vows quick response if Europe provokesUS layoffs dip but hiring hits 16-yr lowPepsiCo has a new challenge on its handsSazerac bets on India whiskey boomHousing sales in Mumbai, Pune fall 17%Too much car tech? Some cos are admitting itEx-RAW chief calls Pak's Munir a jihadiKia targets India hybrid gap with new plan'There will always only be one Jane Goodall'US govt shutdown: Have a visa appointment?Musk becomes first person to have $500 bnTrump wants Nobel, but is unlikely to winTCS drags SpiceJet to court over unpaid billsSmart surfaces: How to cool our citiesOilMin invites applications for BPCL top jobSwiss chocolates and watches get cheaperIndia's tank maker looking to go globalEU to increase tariffs on steel importsTata Motors speeds past Hyundai, M&M
Franchise flicks lose their shineRBI weighs uniform compensation policyDaniel Kretinsky to sell Thyssenkrupp stakePutin vows quick response if Europe provokesUS layoffs dip but hiring hits 16-yr lowPepsiCo has a new challenge on its handsSazerac bets on India whiskey boomHousing sales in Mumbai, Pune fall 17%Too much car tech? Some cos are admitting itEx-RAW chief calls Pak's Munir a jihadiKia targets India hybrid gap with new plan'There will always only be one Jane Goodall'US govt shutdown: Have a visa appointment?Musk becomes first person to have $500 bnTrump wants Nobel, but is unlikely to winTCS drags SpiceJet to court over unpaid billsSmart surfaces: How to cool our citiesOilMin invites applications for BPCL top jobSwiss chocolates and watches get cheaperIndia's tank maker looking to go globalEU to increase tariffs on steel importsTata Motors speeds past Hyundai, M&M More from Top News »
Housing sales in Mumbai, Pune fall 17%
India's tank maker looking to go global
Kia targets India hybrid gap with new plan
Musk becomes first person to have $500 bn
OilMin invites applications for BPCL top job
PepsiCo has a new challenge on its hands
Putin vows quick response if Europe provokes
RBI weighs uniform compensation policy
Sazerac bets on India whiskey boom
Smart surfaces: How to cool our cities
Swiss chocolates and watches get cheaper
TCS drags SpiceJet to court over unpaid bills
Tata Motors speeds past Hyundai, M&M
#Sentiment scoring
## Here we will read in an entire dictionary from Harvard Inquirer
f = open('NLP_data/inqdict.txt')
HIDict = f.read()
HIDict = HIDict.splitlines()
HIDict = HIDict[1:]
print(HIDict[:5])
print(len(HIDict))

#Extract all the lines that contain the Pos tag
poswords = [j for j in HIDict if "Pos" in j]  #using a list comprehension
poswords = [j.split()[0] for j in poswords]
poswords = [j.split("#")[0] for j in poswords]
poswords = unique(poswords)
poswords = [j.lower() for j in poswords]
print(poswords[:20])
print(len(poswords))

#Extract all the lines that contain the Neg tag
negwords = [j for j in HIDict if "Neg" in j]  #using a list comprehension
negwords = [j.split()[0] for j in negwords]
negwords = [j.split("#")[0] for j in negwords]
negwords = unique(negwords)
negwords = [j.lower() for j in negwords]
print(negwords[:20])
print(len(negwords))
['A H4Lvd DET ART  | article: Indefinite singular article--some or any one', 'ABANDON H4Lvd Neg Ngtv Weak Fail IAV AFFLOSS AFFTOT SUPV  |', 'ABANDONMENT H4 Neg Weak Fail Noun  |', 'ABATE H4Lvd Neg Psv Decr IAV TRANS SUPV  |', 'ABATEMENT Lvd Noun  ']
11895
['abide', 'able', 'abound', 'absolve', 'absorbent', 'absorption', 'abundance', 'abundant', 'accede', 'accentuate', 'accept', 'acceptable', 'acceptance', 'accessible', 'accession', 'acclaim', 'acclamation', 'accolade', 'accommodate', 'accommodation']
1646
['abandon', 'abandonment', 'abate', 'abdicate', 'abhor', 'abject', 'abnormal', 'abolish', 'abominable', 'abrasive', 'abrupt', 'abscond', 'absence', 'absent', 'absent-minded', 'absentee', 'absurd', 'absurdity', 'abuse', 'abyss']
2120
#Create a sentiment scoring function
def textSentiment(text,poswords,negwords):
    text.lower(); print(text)
    text = text.split(' ')
    posmatches = set(text).intersection(set(poswords)); print(posmatches)
    negmatches = set(text).intersection(set(negwords)); print(negmatches)
    return [len(posmatches),len(negmatches)]
for h in headlines:
    s = textSentiment(h,poswords,negwords)
    print(s)
'There will always only be one Jane Goodall'
set()
set()
[0, 0]
Daniel Kretinsky to sell Thyssenkrupp stake
set()
set()
[0, 0]
EU to increase tariffs on steel imports
set()
set()
[0, 0]
Ex-RAW chief calls Pak's Munir a jihadi
set()
set()
[0, 0]
Franchise flicks lose their shine
{'their'}
{'lose'}
[1, 1]
Franchise flicks lose their shineRBI weighs uniform compensation policyDaniel Kretinsky to sell Thyssenkrupp stakePutin vows quick response if Europe provokesUS layoffs dip but hiring hits 16-yr lowPepsiCo has a new challenge on its handsSazerac bets on India whiskey boomHousing sales in Mumbai, Pune fall 17%Too much car tech? Some cos are admitting itEx-RAW chief calls Pak's Munir a jihadiKia targets India hybrid gap with new plan'There will always only be one Jane Goodall'US govt shutdown: Have a visa appointment?Musk becomes first person to have $500 bnTrump wants Nobel, but is unlikely to winTCS drags SpiceJet to court over unpaid billsSmart surfaces: How to cool our citiesOilMin invites applications for BPCL top jobSwiss chocolates and watches get cheaperIndia's tank maker looking to go globalEU to increase tariffs on steel importsTata Motors speeds past Hyundai, M&M
{'their', 'compensation', 'have', 'our'}
{'get', 'cool', 'challenge', 'unlikely', 'lose', 'fall'}
[4, 6]
Franchise flicks lose their shineRBI weighs uniform compensation policyDaniel Kretinsky to sell Thyssenkrupp stakePutin vows quick response if Europe provokesUS layoffs dip but hiring hits 16-yr lowPepsiCo has a new challenge on its handsSazerac bets on India whiskey boomHousing sales in Mumbai, Pune fall 17%Too much car tech? Some cos are admitting itEx-RAW chief calls Pak's Munir a jihadiKia targets India hybrid gap with new plan'There will always only be one Jane Goodall'US govt shutdown: Have a visa appointment?Musk becomes first person to have $500 bnTrump wants Nobel, but is unlikely to winTCS drags SpiceJet to court over unpaid billsSmart surfaces: How to cool our citiesOilMin invites applications for BPCL top jobSwiss chocolates and watches get cheaperIndia's tank maker looking to go globalEU to increase tariffs on steel importsTata Motors speeds past Hyundai, M&M More from Top News »
{'their', 'compensation', 'have', 'our'}
{'get', 'cool', 'challenge', 'unlikely', 'lose', 'fall'}
[4, 6]
Housing sales in Mumbai, Pune fall 17%
set()
{'fall'}
[0, 1]
India's tank maker looking to go global
set()
set()
[0, 0]
Kia targets India hybrid gap with new plan
set()
set()
[0, 0]
Musk becomes first person to have $500 bn
{'have'}
set()
[1, 0]
OilMin invites applications for BPCL top job
set()
set()
[0, 0]
PepsiCo has a new challenge on its hands
set()
{'challenge'}
[0, 1]
Putin vows quick response if Europe provokes
set()
set()
[0, 0]
RBI weighs uniform compensation policy
{'compensation'}
set()
[1, 0]
Sazerac bets on India whiskey boom
{'boom'}
set()
[1, 0]
Smart surfaces: How to cool our cities
{'our'}
{'cool'}
[1, 1]
Swiss chocolates and watches get cheaper
set()
{'get'}
[0, 1]
TCS drags SpiceJet to court over unpaid bills
set()
set()
[0, 0]
Tata Motors speeds past Hyundai, M&M
set()
set()
[0, 0]

12.2. Using R for extraction with rvest#

There are various options to run R code in Jupyter:

  1. Run this in a new notebook with the R kernel.

  2. Install rpy2 with pip : pip install rpy2

  3. Install the anaconda package using conda : search for ‘anaconda r-package-name’

  4. Using a R code block, use “install.packages(“r-package-name”)

# !pip install -U rpy2   # run this in the R kernel with: system('pip install rpy2')
# %reload_ext rpy2.ipython
# ! conda install -c conda-forge r-rvest -y
%%R
install.packages(c("magrittr","stringr","rvest"))
Installing packages into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/magrittr_2.0.4.tar.gz'
trying URL 'https://cran.rstudio.com/src/contrib/stringr_1.5.2.tar.gz'
trying URL 'https://cran.rstudio.com/src/contrib/rvest_1.0.5.tar.gz'

The downloaded source packages are in
	‘/tmp/RtmpIJdjpC/downloaded_packages’
%%R
library(rvest)
library(magrittr)
library(stringr)
%%R
url = "https://en.wikipedia.org/wiki/List_of_S%26P_500_companies"
print(url)
doc = read_html(url)
# res = doc %>% html_nodes("table") %>% html_table()
res = doc %>% html_element("table") %>% html_table()
[1] "https://en.wikipedia.org/wiki/List_of_S%26P_500_companies"
%%R
res
# A tibble: 503 × 8
   Symbol Security      `GICS Sector` `GICS Sub-Industry` Headquarters Locatio…¹
   <chr>  <chr>         <chr>         <chr>               <chr>                 
 1 MMM    3M            Industrials   Industrial Conglom… Saint Paul, Minnesota 
 2 AOS    A. O. Smith   Industrials   Building Products   Milwaukee, Wisconsin  
 3 ABT    Abbott Labor… Health Care   Health Care Equipm… North Chicago, Illino…
 4 ABBV   AbbVie        Health Care   Biotechnology       North Chicago, Illino…
 5 ACN    Accenture     Information … IT Consulting & Ot… Dublin, Ireland       
 6 ADBE   Adobe Inc.    Information … Application Softwa… San Jose, California  
 7 AMD    Advanced Mic… Information … Semiconductors      Santa Clara, Californ…
 8 AES    AES Corporat… Utilities     Independent Power … Arlington, Virginia   
 9 AFL    Aflac         Financials    Life & Health Insu… Columbus, Georgia     
10 A      Agilent Tech… Health Care   Life Sciences Tool… Santa Clara, Californ…
# ℹ 493 more rows
# ℹ abbreviated name: ¹​`Headquarters Location`
# ℹ 3 more variables: `Date added` <chr>, CIK <int>, Founded <chr>
# ℹ Use `print(n = ...)` to see more rows
%%R
symbols = res[1]$Symbol
symbols
  [1] "MMM"   "AOS"   "ABT"   "ABBV"  "ACN"   "ADBE"  "AMD"   "AES"   "AFL"  
 [10] "A"     "APD"   "ABNB"  "AKAM"  "ALB"   "ARE"   "ALGN"  "ALLE"  "LNT"  
 [19] "ALL"   "GOOGL" "GOOG"  "MO"    "AMZN"  "AMCR"  "AEE"   "AEP"   "AXP"  
 [28] "AIG"   "AMT"   "AWK"   "AMP"   "AME"   "AMGN"  "APH"   "ADI"   "AON"  
 [37] "APA"   "APO"   "AAPL"  "AMAT"  "APP"   "APTV"  "ACGL"  "ADM"   "ANET" 
 [46] "AJG"   "AIZ"   "T"     "ATO"   "ADSK"  "ADP"   "AZO"   "AVB"   "AVY"  
 [55] "AXON"  "BKR"   "BALL"  "BAC"   "BAX"   "BDX"   "BRK.B" "BBY"   "TECH" 
 [64] "BIIB"  "BLK"   "BX"    "XYZ"   "BK"    "BA"    "BKNG"  "BSX"   "BMY"  
 [73] "AVGO"  "BR"    "BRO"   "BF.B"  "BLDR"  "BG"    "BXP"   "CHRW"  "CDNS" 
 [82] "CPT"   "CPB"   "COF"   "CAH"   "KMX"   "CCL"   "CARR"  "CAT"   "CBOE" 
 [91] "CBRE"  "CDW"   "COR"   "CNC"   "CNP"   "CF"    "CRL"   "SCHW"  "CHTR" 
[100] "CVX"   "CMG"   "CB"    "CHD"   "CI"    "CINF"  "CTAS"  "CSCO"  "C"    
[109] "CFG"   "CLX"   "CME"   "CMS"   "KO"    "CTSH"  "COIN"  "CL"    "CMCSA"
[118] "CAG"   "COP"   "ED"    "STZ"   "CEG"   "COO"   "CPRT"  "GLW"   "CPAY" 
[127] "CTVA"  "CSGP"  "COST"  "CTRA"  "CRWD"  "CCI"   "CSX"   "CMI"   "CVS"  
[136] "DHR"   "DRI"   "DDOG"  "DVA"   "DAY"   "DECK"  "DE"    "DELL"  "DAL"  
[145] "DVN"   "DXCM"  "FANG"  "DLR"   "DG"    "DLTR"  "D"     "DPZ"   "DASH" 
[154] "DOV"   "DOW"   "DHI"   "DTE"   "DUK"   "DD"    "EMN"   "ETN"   "EBAY" 
[163] "ECL"   "EIX"   "EW"    "EA"    "ELV"   "EME"   "EMR"   "ETR"   "EOG"  
[172] "EPAM"  "EQT"   "EFX"   "EQIX"  "EQR"   "ERIE"  "ESS"   "EL"    "EG"   
[181] "EVRG"  "ES"    "EXC"   "EXE"   "EXPE"  "EXPD"  "EXR"   "XOM"   "FFIV" 
[190] "FDS"   "FICO"  "FAST"  "FRT"   "FDX"   "FIS"   "FITB"  "FSLR"  "FE"   
[199] "FI"    "F"     "FTNT"  "FTV"   "FOXA"  "FOX"   "BEN"   "FCX"   "GRMN" 
[208] "IT"    "GE"    "GEHC"  "GEV"   "GEN"   "GNRC"  "GD"    "GIS"   "GM"   
[217] "GPC"   "GILD"  "GPN"   "GL"    "GDDY"  "GS"    "HAL"   "HIG"   "HAS"  
[226] "HCA"   "DOC"   "HSIC"  "HSY"   "HPE"   "HLT"   "HOLX"  "HD"    "HON"  
[235] "HRL"   "HST"   "HWM"   "HPQ"   "HUBB"  "HUM"   "HBAN"  "HII"   "IBM"  
[244] "IEX"   "IDXX"  "ITW"   "INCY"  "IR"    "PODD"  "INTC"  "IBKR"  "ICE"  
[253] "IFF"   "IP"    "IPG"   "INTU"  "ISRG"  "IVZ"   "INVH"  "IQV"   "IRM"  
[262] "JBHT"  "JBL"   "JKHY"  "J"     "JNJ"   "JCI"   "JPM"   "K"     "KVUE" 
[271] "KDP"   "KEY"   "KEYS"  "KMB"   "KIM"   "KMI"   "KKR"   "KLAC"  "KHC"  
[280] "KR"    "LHX"   "LH"    "LRCX"  "LW"    "LVS"   "LDOS"  "LEN"   "LII"  
[289] "LLY"   "LIN"   "LYV"   "LKQ"   "LMT"   "L"     "LOW"   "LULU"  "LYB"  
[298] "MTB"   "MPC"   "MAR"   "MMC"   "MLM"   "MAS"   "MA"    "MTCH"  "MKC"  
[307] "MCD"   "MCK"   "MDT"   "MRK"   "META"  "MET"   "MTD"   "MGM"   "MCHP" 
[316] "MU"    "MSFT"  "MAA"   "MRNA"  "MHK"   "MOH"   "TAP"   "MDLZ"  "MPWR" 
[325] "MNST"  "MCO"   "MS"    "MOS"   "MSI"   "MSCI"  "NDAQ"  "NTAP"  "NFLX" 
[334] "NEM"   "NWSA"  "NWS"   "NEE"   "NKE"   "NI"    "NDSN"  "NSC"   "NTRS" 
[343] "NOC"   "NCLH"  "NRG"   "NUE"   "NVDA"  "NVR"   "NXPI"  "ORLY"  "OXY"  
[352] "ODFL"  "OMC"   "ON"    "OKE"   "ORCL"  "OTIS"  "PCAR"  "PKG"   "PLTR" 
[361] "PANW"  "PSKY"  "PH"    "PAYX"  "PAYC"  "PYPL"  "PNR"   "PEP"   "PFE"  
[370] "PCG"   "PM"    "PSX"   "PNW"   "PNC"   "POOL"  "PPG"   "PPL"   "PFG"  
[379] "PG"    "PGR"   "PLD"   "PRU"   "PEG"   "PTC"   "PSA"   "PHM"   "PWR"  
[388] "QCOM"  "DGX"   "RL"    "RJF"   "RTX"   "O"     "REG"   "REGN"  "RF"   
[397] "RSG"   "RMD"   "RVTY"  "HOOD"  "ROK"   "ROL"   "ROP"   "ROST"  "RCL"  
[406] "SPGI"  "CRM"   "SBAC"  "SLB"   "STX"   "SRE"   "NOW"   "SHW"   "SPG"  
[415] "SWKS"  "SJM"   "SW"    "SNA"   "SOLV"  "SO"    "LUV"   "SWK"   "SBUX" 
[424] "STT"   "STLD"  "STE"   "SYK"   "SMCI"  "SYF"   "SNPS"  "SYY"   "TMUS" 
[433] "TROW"  "TTWO"  "TPR"   "TRGP"  "TGT"   "TEL"   "TDY"   "TER"   "TSLA" 
[442] "TXN"   "TPL"   "TXT"   "TMO"   "TJX"   "TKO"   "TTD"   "TSCO"  "TT"   
[451] "TDG"   "TRV"   "TRMB"  "TFC"   "TYL"   "TSN"   "USB"   "UBER"  "UDR"  
[460] "ULTA"  "UNP"   "UAL"   "UPS"   "URI"   "UNH"   "UHS"   "VLO"   "VTR"  
[469] "VLTO"  "VRSN"  "VRSK"  "VZ"    "VRTX"  "VTRS"  "VICI"  "V"     "VST"  
[478] "VMC"   "WRB"   "GWW"   "WAB"   "WMT"   "DIS"   "WBD"   "WM"    "WAT"  
[487] "WEC"   "WFC"   "WELL"  "WST"   "WDC"   "WY"    "WSM"   "WMB"   "WTW"  
[496] "WDAY"  "WYNN"  "XEL"   "XYL"   "YUM"   "ZBRA"  "ZBH"   "ZTS"  
%%R
res = doc %>% html_nodes("p") %>% html_text()
print(res)
[1] "\nThe S&P 500 is a stock market index maintained by S&P Dow Jones Indices. It comprises 503 common stocks which are issued by 500 large-cap companies traded on the American stock exchanges (including the 30 companies that compose the Dow Jones Industrial Average). The index includes about 80 percent of the American market by capitalization. It is weighted by free-float market capitalization, so more valuable companies account for relatively more weight in the index. The index constituents and the constituent weights are updated regularly using rules published by S&P Dow Jones Indices. Although called the S&P 500, the index contains 503 stocks because it includes two share classes of stock from 3 of its component companies.[1][2]"
[2] "S&P Dow Jones Indices updates the components of the S&P 500 periodically, typically in response to acquisitions, or to keep the index up to date as various companies grow or shrink in value.[3] Between January 1, 1963, and December 31, 2014, 1,186 index components were replaced by other components.\n"                                                                                                                                                                                                                                                                                                                                                                                                                                                     
syms = %Rget symbols
syms
array(['MMM', 'AOS', 'ABT', 'ABBV', 'ACN', 'ADBE', 'AMD', 'AES', 'AFL',
       'A', 'APD', 'ABNB', 'AKAM', 'ALB', 'ARE', 'ALGN', 'ALLE', 'LNT',
       'ALL', 'GOOGL', 'GOOG', 'MO', 'AMZN', 'AMCR', 'AEE', 'AEP', 'AXP',
       'AIG', 'AMT', 'AWK', 'AMP', 'AME', 'AMGN', 'APH', 'ADI', 'AON',
       'APA', 'APO', 'AAPL', 'AMAT', 'APP', 'APTV', 'ACGL', 'ADM', 'ANET',
       'AJG', 'AIZ', 'T', 'ATO', 'ADSK', 'ADP', 'AZO', 'AVB', 'AVY',
       'AXON', 'BKR', 'BALL', 'BAC', 'BAX', 'BDX', 'BRK.B', 'BBY', 'TECH',
       'BIIB', 'BLK', 'BX', 'XYZ', 'BK', 'BA', 'BKNG', 'BSX', 'BMY',
       'AVGO', 'BR', 'BRO', 'BF.B', 'BLDR', 'BG', 'BXP', 'CHRW', 'CDNS',
       'CPT', 'CPB', 'COF', 'CAH', 'KMX', 'CCL', 'CARR', 'CAT', 'CBOE',
       'CBRE', 'CDW', 'COR', 'CNC', 'CNP', 'CF', 'CRL', 'SCHW', 'CHTR',
       'CVX', 'CMG', 'CB', 'CHD', 'CI', 'CINF', 'CTAS', 'CSCO', 'C',
       'CFG', 'CLX', 'CME', 'CMS', 'KO', 'CTSH', 'COIN', 'CL', 'CMCSA',
       'CAG', 'COP', 'ED', 'STZ', 'CEG', 'COO', 'CPRT', 'GLW', 'CPAY',
       'CTVA', 'CSGP', 'COST', 'CTRA', 'CRWD', 'CCI', 'CSX', 'CMI', 'CVS',
       'DHR', 'DRI', 'DDOG', 'DVA', 'DAY', 'DECK', 'DE', 'DELL', 'DAL',
       'DVN', 'DXCM', 'FANG', 'DLR', 'DG', 'DLTR', 'D', 'DPZ', 'DASH',
       'DOV', 'DOW', 'DHI', 'DTE', 'DUK', 'DD', 'EMN', 'ETN', 'EBAY',
       'ECL', 'EIX', 'EW', 'EA', 'ELV', 'EME', 'EMR', 'ETR', 'EOG',
       'EPAM', 'EQT', 'EFX', 'EQIX', 'EQR', 'ERIE', 'ESS', 'EL', 'EG',
       'EVRG', 'ES', 'EXC', 'EXE', 'EXPE', 'EXPD', 'EXR', 'XOM', 'FFIV',
       'FDS', 'FICO', 'FAST', 'FRT', 'FDX', 'FIS', 'FITB', 'FSLR', 'FE',
       'FI', 'F', 'FTNT', 'FTV', 'FOXA', 'FOX', 'BEN', 'FCX', 'GRMN',
       'IT', 'GE', 'GEHC', 'GEV', 'GEN', 'GNRC', 'GD', 'GIS', 'GM', 'GPC',
       'GILD', 'GPN', 'GL', 'GDDY', 'GS', 'HAL', 'HIG', 'HAS', 'HCA',
       'DOC', 'HSIC', 'HSY', 'HPE', 'HLT', 'HOLX', 'HD', 'HON', 'HRL',
       'HST', 'HWM', 'HPQ', 'HUBB', 'HUM', 'HBAN', 'HII', 'IBM', 'IEX',
       'IDXX', 'ITW', 'INCY', 'IR', 'PODD', 'INTC', 'IBKR', 'ICE', 'IFF',
       'IP', 'IPG', 'INTU', 'ISRG', 'IVZ', 'INVH', 'IQV', 'IRM', 'JBHT',
       'JBL', 'JKHY', 'J', 'JNJ', 'JCI', 'JPM', 'K', 'KVUE', 'KDP', 'KEY',
       'KEYS', 'KMB', 'KIM', 'KMI', 'KKR', 'KLAC', 'KHC', 'KR', 'LHX',
       'LH', 'LRCX', 'LW', 'LVS', 'LDOS', 'LEN', 'LII', 'LLY', 'LIN',
       'LYV', 'LKQ', 'LMT', 'L', 'LOW', 'LULU', 'LYB', 'MTB', 'MPC',
       'MAR', 'MMC', 'MLM', 'MAS', 'MA', 'MTCH', 'MKC', 'MCD', 'MCK',
       'MDT', 'MRK', 'META', 'MET', 'MTD', 'MGM', 'MCHP', 'MU', 'MSFT',
       'MAA', 'MRNA', 'MHK', 'MOH', 'TAP', 'MDLZ', 'MPWR', 'MNST', 'MCO',
       'MS', 'MOS', 'MSI', 'MSCI', 'NDAQ', 'NTAP', 'NFLX', 'NEM', 'NWSA',
       'NWS', 'NEE', 'NKE', 'NI', 'NDSN', 'NSC', 'NTRS', 'NOC', 'NCLH',
       'NRG', 'NUE', 'NVDA', 'NVR', 'NXPI', 'ORLY', 'OXY', 'ODFL', 'OMC',
       'ON', 'OKE', 'ORCL', 'OTIS', 'PCAR', 'PKG', 'PLTR', 'PANW', 'PSKY',
       'PH', 'PAYX', 'PAYC', 'PYPL', 'PNR', 'PEP', 'PFE', 'PCG', 'PM',
       'PSX', 'PNW', 'PNC', 'POOL', 'PPG', 'PPL', 'PFG', 'PG', 'PGR',
       'PLD', 'PRU', 'PEG', 'PTC', 'PSA', 'PHM', 'PWR', 'QCOM', 'DGX',
       'RL', 'RJF', 'RTX', 'O', 'REG', 'REGN', 'RF', 'RSG', 'RMD', 'RVTY',
       'HOOD', 'ROK', 'ROL', 'ROP', 'ROST', 'RCL', 'SPGI', 'CRM', 'SBAC',
       'SLB', 'STX', 'SRE', 'NOW', 'SHW', 'SPG', 'SWKS', 'SJM', 'SW',
       'SNA', 'SOLV', 'SO', 'LUV', 'SWK', 'SBUX', 'STT', 'STLD', 'STE',
       'SYK', 'SMCI', 'SYF', 'SNPS', 'SYY', 'TMUS', 'TROW', 'TTWO', 'TPR',
       'TRGP', 'TGT', 'TEL', 'TDY', 'TER', 'TSLA', 'TXN', 'TPL', 'TXT',
       'TMO', 'TJX', 'TKO', 'TTD', 'TSCO', 'TT', 'TDG', 'TRV', 'TRMB',
       'TFC', 'TYL', 'TSN', 'USB', 'UBER', 'UDR', 'ULTA', 'UNP', 'UAL',
       'UPS', 'URI', 'UNH', 'UHS', 'VLO', 'VTR', 'VLTO', 'VRSN', 'VRSK',
       'VZ', 'VRTX', 'VTRS', 'VICI', 'V', 'VST', 'VMC', 'WRB', 'GWW',
       'WAB', 'WMT', 'DIS', 'WBD', 'WM', 'WAT', 'WEC', 'WFC', 'WELL',
       'WST', 'WDC', 'WY', 'WSM', 'WMB', 'WTW', 'WDAY', 'WYNN', 'XEL',
       'XYL', 'YUM', 'ZBRA', 'ZBH', 'ZTS'], dtype='<U5')
x = 3
%Rpush x
%%R
x
[1] 3