0

I'm working on a google sheet that will import info from Airdna.co but when I try to use the =IMPORTXML I run into a problem because it has double quotes inside.

Here is the formula I'm trying to use:

=IMPORTXML(B2,"//*[@id="app"]/section/div[2]/div/div/div/div/div[2]/div/div[1]/div[1]/div[1]","en-US")

This formula won't work because the starting quotes are ended at "app" but I need the whole XPath contained in " ".

I've tried to use =CONCAT to build the XPath the way I want it but I'm still kinda new to XPATH and haven't found a solution to this yet.

Tyson Biegler
  • 68
  • 1
  • 11
  • What if instead of using ```id``` you use ```div class``` like: ```=IMPORTXML("AirDNAURLHere","//div[@class= 'The class of your Div containing the data you want here']")``` you can get the div class by using the ```Inspect``` from the browser (I am using Chromem not sure for others) – Yancy Godoy Aug 02 '22 at 21:08
  • Yeah I tried that too and it didnt work either. =IMPORTXML("https://www.airdna.co/vacation-rental-data/app/us/oregon/portland/overview","/div[@class='box-overall__value']") – Tyson Biegler Aug 02 '22 at 21:19
  • Can I ask you about the URL and your expected value? – Tanaike Aug 02 '22 at 23:01
  • This site https://www.airdna.co/vacation-rental-data/app/us/oregon/portland/overview uses javascript, so you won't be able to use the native function like importxml. – Mike Steelson Aug 03 '22 at 01:07

2 Answers2

1

This site https://www.airdna.co/vacation-rental-data/app/us/oregon/portland/overview uses javascript, so you won't be able to use the native function like importxml.

How to know if Google Sheets IMPORTDATA, IMPORTFEED, IMPORTHTML or IMPORTXML functions are able to get data

Mike Steelson
  • 14,650
  • 2
  • 5
  • 20
0

use single-quotes:

=IMPORTXML(B2,"//*[@id='app']/section/div[2]/div/div/div/div/div[2]/div/div[1]/div[1]/div[1]","en-US")
player0
  • 124,011
  • 12
  • 67
  • 124
  • That was the first thing I tried but it just says "Error Imported content is empty." – Tyson Biegler Aug 02 '22 at 20:37
  • 2
    That's progress though; at least now your XPath is valid; it just doesn't return what you want it to. If you want help with that, you should ask another question and give an example of the XPath and the HTML page which you are trying to query. NB one common reason why IMPORTXML would return nothing is that the web page is dynamically constructed by JavaScript; if you view the HTML source and the HTML is not there, then that's your real problem. IMPORTXML doesn't run JavaScript. – Conal Tuohy Aug 02 '22 at 22:28