1

I am trying to create a Google Sheet to combine several peoples' board game collections. I want the sheet to pull information about each game from boardgamegeek.com.

Example Page: https://boardgamegeek.com/boardgame/131357/coup

I want to pull information from this page such as the average rating (7.1, in this case), the number of players, playing time, ages, weight, etc.

I'm trying to use the following formula to pull the weight from the page:

=IMPORTXML("https://boardgamegeek.com/boardgame/131357/coup","//*[contains(concat( ' ', @class, ' ' ), concat( ' ', 'gameplay-weight-light', ' ' ))]")

I used the SelectorGadget extension for Chrome to get the XPath. I have successfully used it in similar formulas to get information from other websites, but when I try to pull from boardgamegeek, I get an

Error: Imported Content is Empty.

Based on what I've read, I think the issue is that the things I'm trying to pull from the page are not static, they are calculated from another source, and I need to find that source page. However, I can't seem to find any direction on how to find the page I would need. If anyone could point me in the right direction (or point out something I'm doing wrong with my formula) I would greatly appreciate it!

4
  • Did you already reviewed if the source code of the web page has the content that you want to import? Commented Nov 5, 2017 at 18:23
  • You mean just looking at the page source (ctrl-U in chrome)? I have looked at it, and I see some of the numbers I'm looking for in the <script> section {"usersrated":"22998","average":"7.10457","baverage":"6.98848","stddev":"1.39385","avgweight":"1.4358"... but I don't know how to pull them from the source like that into my sheet.
    – atomiczap
    Commented Nov 5, 2017 at 18:34
  • Yes, I meant to look at the content shown by pressing <kbd>CRTL</kbd>+<kbd>U</kbd>. Some pages use JavaScript or other means to change the DOM but IMPORTXML can't see those changes. Commented Nov 5, 2017 at 18:37
  • Right, I think that is the problem (the number coming from a script). When other people have asked similar questions, I've seen people find the page that those numbers actually come from (the ones the script pulls from), but no one ever explains how they found the page. Any idea how people would find that?
    – atomiczap
    Commented Nov 5, 2017 at 18:39

1 Answer 1

1

Some tools that give the xPath are able to read the DOM of the related page after it was modified but IMPORTXML is only able to read the source code of the page. In these cases, you should use another tool or manually find out the xPath.

Related

4
  • I really don't know much about xPaths, so I'm afraid I don't know how to find them manually. I have been messing around with the "XPath Helper" extension, which gives me much longer xPaths than SelectorGadget, but I'm still getting the same error in Sheets (tried starting a new sheet as well, just in case). Do you know of a tool that is likely to work?
    – atomiczap
    Commented Nov 5, 2017 at 19:18
  • @atomiczap Ask on Software Recommendations. Commented Nov 5, 2017 at 19:29
  • 1
    Thanks for your help! I've been doing tons of reading and have learned a lot (funny how that works sometimes). I have found the page that I can pull from and figured out how to get the xPaths for most of what is there, but I'm having trouble with the last bit I want to pull. boardgamegeek.com/xmlapi/boardgame/68448&stats=1 Near the bottom of the page I am trying to get the "Board Game Rank" (the value of 39 is what I want). The xPath I'm trying is //boardgames/boardgame/statistics/ratings/ranks/rank[1]/value but that isn't right. How do I get the value inside the <>?
    – atomiczap
    Commented Nov 5, 2017 at 22:54
  • 1
    I got it! I needed @value. Thanks again for your help!
    – atomiczap
    Commented Nov 5, 2017 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.