1
votes

I am trying to import a number of texts into google sheets, from this website: https://www.nrl.com/draw/nrl-premiership/2021/round-10/sharks-v-rabbitohs/

The first one I'm trying to do is import team names into sheets but everything I do comes up with #N/A: Imported content is empty error. I have tried all of the following:

=IMPORTXML("https://www.nrl.com/draw/nrl-premiership/2021/round-10/sharks-v-rabbitohs/", "//*[@id='match-team__info match-team__info--home']")

=IMPORTXML("https://www.nrl.com/draw/nrl-premiership/2021/round-10/sharks-v-rabbitohs/", "//div[contains(@class, 'match-team__info match-team__info--home')]")

=IMPORTXML("https://www.nrl.com/draw/nrl-premiership/2021/round-10/sharks-v-rabbitohs/", "//p[contains(@class, 'match-team__info match-team__info--home')]")

=IMPORTXML("https://www.nrl.com/draw/nrl-premiership/2021/round-10/sharks-v-rabbitohs/", "//*[@id='match-team__info match-team__info--home']/p")

=IMPORTXML("https://www.nrl.com/draw/nrl-premiership/2021/round-10/sharks-v-rabbitohs/", "//div[contains(@class, 'match-team__info match-team__info--home')]/p")

Generally I am trying to import things from the page such as: team name, position and statistics below

If anyone could help shed some light on what I am doing wrong I would appreciate it greatly... cheers

1

1 Answers

2
votes

The reason is that the web page is built on your side and not on server side, by javascript. But all datas you need are contained in a json (id=vue-match-centre). So you can get data with

=importxml(url,"//div[@id='vue-match-centre']//@q-data")

and then parse the json, for instance with this script

function who(jsonstring){
  var data = JSON.parse(jsonstring.replace(/\n/g,''))
  return [data.match.homeTeam.nickName,data.match.awayTeam.nickName]
}

you will be able to fetch the names by

=who(importxml(A1,"//div[@id='vue-match-centre']//@q-data"))