0

I'm trying to import some text from the internet but apparently google sheets doesn't handle dinamic websites. I used the Xpath from Chrome browser.

These were the solutions that I was working on but none of them worked.

=IMPORTXML("https://www.kite.com/python/docs/pandas.core.frame.DataFrame.sum","//*[@id='root']/div/div/div[3]/div/div/div/div[2]/section/div/code/text()") 

=INDEX(IMPORTXML("https://www.kite.com/python/docs/pandas.core.frame.DataFrame.sum","//*[@id='root']/div/div/div[3]/div/div/div/div[2]/section/div/code/text()"),1;1)

Any help is welcome.

Rubén
  • 34,714
  • 9
  • 70
  • 166
Artur Dutra
  • 515
  • 3
  • 18
  • Can I ask you about the values you want to retrieve? – Tanaike Sep 09 '20 at 23:30
  • I want to retrieve the documentation about the function. – Artur Dutra Sep 09 '20 at 23:42
  • 1
    Thank you for replying. When I saw the HTML of the URL, it seems that the document you want is shown using Javascript. In this case, the values cannot be directly retrieved using IMPORTXML. I think that the reason of your issue is due to this. I apologize for this. – Tanaike Sep 09 '20 at 23:48
  • Does this answer your question? [Importxml Imported Content Empty](https://stackoverflow.com/questions/34217955/importxml-imported-content-empty) – Rubén Sep 10 '20 at 00:09
  • I searched them all, I couldn't manage to find a way around that. But thanks though – Artur Dutra Sep 10 '20 at 00:15

1 Answers1

0

You're trying to get the Documentation text, I see.

As you have found out, you cannot simply ImportXML() for dynamic data in websites. Instead, what you need to do is look for how the data is getting retrieved. My first instinct is always to check the Network Monitor. I found that it was calling https://alpha.kite.com/api/editor/symbol/python;pandas.core.frame.DataFrame.sum via HTTP GET. The response is a JSON with our data whose path is /report/description_text.

This means we need a way to parse JSON data, which we can do with the Apps Script ImportJSON. Add that script to your sheet (Tools > Script Editor), then:

=ImportJSON("https://alpha.kite.com/api/editor/symbol/python;pandas.core.frame.DataFrame.sum","/report/description_text","noHeaders")

And that should give you the text you want.

General Grievance
  • 4,555
  • 31
  • 31
  • 45