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[:30]   #Needed to exclude any other stuff that was not needed.
for h in headlines:
    print(h)
56
A clear pattern emerges in UPI vs cards battle
Addressing India’s cognitive time bomb
Air India partners with STARLUX Airlines
Arunachal Pradesh bans Coldrif cough syrup
Bira plans $132 million fundraising: Report
British Airways plans new London-Delhi flight
DGCA slaps ₹20 lakh penalty on IndiGo
Earthquake of magnitude 3.1 strikes Bhutan
Govt plans pension law for coal workers
How Donald Trump pulled off his Gaza deal
IMC: India's telecom road map beyond 5G
Indian seafood exporters in troubled water
International students face fewer risks abroad
JSW MG wants to top India's luxe EV market
Modi inaugurates India Mobile Congress 2025
National Employment Policy coming soon
No visas on the table with India: Starmer
PM hails Mumbai Metro Line-3 Phase 2B
Sept third-hottest globally on record
Sept third-hottest globally on recordWhat we know about the new Gaza dealHow Donald Trump pulled off his Gaza dealEarthquake of magnitude 3.1 strikes BhutanNo visas on the table with India: StarmerJSW MG wants to top India's luxe EV marketNational Employment Policy coming soonGovt plans pension law for coal workersDGCA slaps ₹20 lakh penalty on IndiGoPM hails Mumbai Metro Line-3 Phase 2BTCS Q2 earnings press conference called offA clear pattern emerges in UPI vs cards battleSkoda planning to launch EV in IndiaAddressing India’s cognitive time bombAir India partners with STARLUX AirlinesArunachal Pradesh bans Coldrif cough syrupInternational students face fewer risks abroadBira plans $132 million fundraising: ReportIMC: India's telecom road map beyond 5GModi inaugurates India Mobile Congress 2025Indian seafood exporters in troubled waterBritish Airways plans new London-Delhi flight
Sept third-hottest globally on recordWhat we know about the new Gaza dealHow Donald Trump pulled off his Gaza dealEarthquake of magnitude 3.1 strikes BhutanNo visas on the table with India: StarmerJSW MG wants to top India's luxe EV marketNational Employment Policy coming soonGovt plans pension law for coal workersDGCA slaps ₹20 lakh penalty on IndiGoPM hails Mumbai Metro Line-3 Phase 2BTCS Q2 earnings press conference called offA clear pattern emerges in UPI vs cards battleSkoda planning to launch EV in IndiaAddressing India’s cognitive time bombAir India partners with STARLUX AirlinesArunachal Pradesh bans Coldrif cough syrupInternational students face fewer risks abroadBira plans $132 million fundraising: ReportIMC: India's telecom road map beyond 5GModi inaugurates India Mobile Congress 2025Indian seafood exporters in troubled waterBritish Airways plans new London-Delhi flight More from Top News »
Skoda planning to launch EV in India
TCS Q2 earnings press conference called off
What we know about the new Gaza deal
#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)
A clear pattern emerges in UPI vs cards battle
{'clear'}
{'battle'}
[1, 1]
Addressing India’s cognitive time bomb
set()
{'bomb'}
[0, 1]
Air India partners with STARLUX Airlines
set()
set()
[0, 0]
Arunachal Pradesh bans Coldrif cough syrup
set()
set()
[0, 0]
Bira plans $132 million fundraising: Report
set()
set()
[0, 0]
British Airways plans new London-Delhi flight
set()
set()
[0, 0]
DGCA slaps ₹20 lakh penalty on IndiGo
set()
set()
[0, 0]
Earthquake of magnitude 3.1 strikes Bhutan
set()
set()
[0, 0]
Govt plans pension law for coal workers
{'law'}
set()
[1, 0]
How Donald Trump pulled off his Gaza deal
{'his', 'deal'}
{'deal'}
[2, 1]
IMC: India's telecom road map beyond 5G
set()
set()
[0, 0]
Indian seafood exporters in troubled water
set()
set()
[0, 0]
International students face fewer risks abroad
set()
set()
[0, 0]
JSW MG wants to top India's luxe EV market
set()
set()
[0, 0]
Modi inaugurates India Mobile Congress 2025
set()
set()
[0, 0]
National Employment Policy coming soon
set()
set()
[0, 0]
No visas on the table with India: Starmer
set()
set()
[0, 0]
PM hails Mumbai Metro Line-3 Phase 2B
set()
set()
[0, 0]
Sept third-hottest globally on record
set()
set()
[0, 0]
Sept third-hottest globally on recordWhat we know about the new Gaza dealHow Donald Trump pulled off his Gaza dealEarthquake of magnitude 3.1 strikes BhutanNo visas on the table with India: StarmerJSW MG wants to top India's luxe EV marketNational Employment Policy coming soonGovt plans pension law for coal workersDGCA slaps ₹20 lakh penalty on IndiGoPM hails Mumbai Metro Line-3 Phase 2BTCS Q2 earnings press conference called offA clear pattern emerges in UPI vs cards battleSkoda planning to launch EV in IndiaAddressing India’s cognitive time bombAir India partners with STARLUX AirlinesArunachal Pradesh bans Coldrif cough syrupInternational students face fewer risks abroadBira plans $132 million fundraising: ReportIMC: India's telecom road map beyond 5GModi inaugurates India Mobile Congress 2025Indian seafood exporters in troubled waterBritish Airways plans new London-Delhi flight
{'his', 'clear', 'know', 'law'}
{'press'}
[4, 1]
Sept third-hottest globally on recordWhat we know about the new Gaza dealHow Donald Trump pulled off his Gaza dealEarthquake of magnitude 3.1 strikes BhutanNo visas on the table with India: StarmerJSW MG wants to top India's luxe EV marketNational Employment Policy coming soonGovt plans pension law for coal workersDGCA slaps ₹20 lakh penalty on IndiGoPM hails Mumbai Metro Line-3 Phase 2BTCS Q2 earnings press conference called offA clear pattern emerges in UPI vs cards battleSkoda planning to launch EV in IndiaAddressing India’s cognitive time bombAir India partners with STARLUX AirlinesArunachal Pradesh bans Coldrif cough syrupInternational students face fewer risks abroadBira plans $132 million fundraising: ReportIMC: India's telecom road map beyond 5GModi inaugurates India Mobile Congress 2025Indian seafood exporters in troubled waterBritish Airways plans new London-Delhi flight More from Top News »
{'his', 'clear', 'know', 'law'}
{'press'}
[4, 1]
Skoda planning to launch EV in India
set()
set()
[0, 0]
TCS Q2 earnings press conference called off
set()
{'press'}
[0, 1]
What we know about the new Gaza deal
{'deal', 'know'}
{'deal'}
[2, 1]

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