1

i am trying to use the importxml function to get data off the following website

:https://fantasy.espn.com/basketball/league/standings?leagueId=1878319. I want to get the table titled final standings into a google sheet using the import xml function. The function i am using is listed below:

=IMPORTXML("https://fantasy.espn.com/basketball/league/standings?leagueId=1878319","//*[@id="espn-analytics"]/div/div[5]/div[2]/div[1]/div/div/div[4]/section/div/div/div[2]/table/tbody")

The function returns a #NA error and says the import is empty. How do i fix it to get the data set i need

dwebb
  • 63
  • 8

1 Answers1

1

Unfortunately as more sites move to dynamically loaded content, the IMPORTXML function is losing some of it's usefulness, as it can't read this. Depending on how the site is loading the content, you might be able to analyze the script and find the source, but it might be true pain to do so, and you may have to parse the format to make it work. No fun.

Since the page you referenced is a "Final Standings" - I assume you don't need this to be auto-updating since it won't change, in which case, rather than a messy copy-paste, you might want to try a Chrome extension like "Instant Web Scraper" which will analyze the tables even within dynamic content and let you export it as a CSV which you can then quickly bring into Google Sheets.

Sorry that doesn't fix the IMPORTXML issue in this case, but I hope it helps.

Edit: Here is that top table in a CSV format (copy and save to a text file and name the text file a .csv and you can then upload it to Google Sheets):

jsx-2810852873,Image src,teamName,jsx-2302882246,Table__TD,jsx-2810852873 2,jsx-2810852873 3,jsx-2810852873 4,jsx-2810852873 5,jsx-2810852873 6,dn src
1,https://g.espncdn.com/lm-static/logo-packs/core/CatsAndDogs/cats_dogs-3.svg,Kevin Manning Show,(Kevin Manning),16-3-1,20328.5,17509.5,1016.4,875.5,+140.9,
2,,los angeles lebrons,(Zack Woodard),15-4-1,20909.5,17702.5,1045.5,885.1,+160.3,https://larrybrownsports.com/wp-content/uploads/2013/11/lebron-james-face.jpg
3,,BasketBall Chimps,(Jacob Woodard),13-6-1,19189.0,17317.5,959.5,865.9,+93.6,https://www.kimballstock.com/pix/CHI/03/CHI_03_RK0299_01_P.JPG
4,https://g.espncdn.com/lm-static/logo-packs/core/DIS_Avengers_EndGame/DIS_Avengers_EndGame_Capt_America.svg,Mr.Clean ICE,(Kenil Prajapati),12-7-1,21134.0,17640.5,1056.7,882.0,+174.7,
5,https://g.espncdn.com/lm-static/logo-packs/core/OldTimeMickeyAndFriends/Hockey_Donald.svg,Yonkers Yoinkers,(Einar H),11-8-1,17317.5,16704.5,865.9,835.2,+30.6,
6,,Yogurt  Slingers,(Allan Perez),8-11-1,15821.5,16717.5,791.1,835.9,-44.8,https://g.espncdn.com/lm-app/lm/img/shell/shield-FBA.svg
7,https://g.espncdn.com/lm-static/logo-packs/core/TeamMascots-RobbHarskamp/Team_Mascots-04.svg,TAMU Shauced Shnacks,(Enrique Baqueiro),10-9-1,19733.5,17396.0,986.7,869.8,+116.9,
8,https://g.espncdn.com/lm-static/fba/images/default_logos/1.svg,Htown  Dal,(sheshu chandrasekar),3-16-1,13393.5,18560.5,669.7,928.0,-258.4,
9,https://g.espncdn.com/lm-static/logo-packs/fba/DreamTeam-ESPN/dreamTeam-4.svg,Original Gayngster,(Lee Nguyen),7-12-1,14462.0,17812.0,723.1,890.6,-167.5,
10,https://g.espncdn.com/lm-static/logo-packs/fba/Jerseys-ESPN/fba-jerseys-10.svg,Musty Burger FC Juan Prado,(Juan Prado),0-19-1,13300.5,18229.0,665.0,911.5,-246.4,
  • Thanks @campbellsea. Is there a way i can use importxml to get the data in the table as it is now. i am not intrested in the auto-updating aspect for now – dwebb Jul 29 '20 at 18:18
  • @dwebb Sorry, but no. It doesn't look like importxml can handle the dynamic content on that page. I've poked around on it. The data is in a react/javascript wrapper (specifically jsx-2810852873 for the top table) and I don't know of any way to get importxml to read that. Maybe someone else will? Hopefully Google will overhaul that function at some point. Best for now is to use "Instant Web Scraper" to grab a CSV. Added CSV for top table in my answer above. I prefer the "Web Scraper" extension for Chrome as it crawls better, but it also has issues with dynamic content sometimes. – campbellsea Jul 29 '20 at 22:52