Google Sheets Script ImportXML

94 views
Skip to first unread message

Juan Carlos Gómez

unread,
Nov 21, 2023, 8:41:48 AM11/21/23
to Google Apps Script Community
Hello,

I want to retrieve data from a financial website (https://www.boerse-frankfurt.de).

I saw a script posted by someone on StackOverFlow that correctly retrieves the data for a specific URL (https://www.boerse-frankfurt.de/en/etf/ishares-s-p-500-energy-sector-ucits-etf-usd-acc).

I want to use the same script but for other URLs of the same web, for example, for: https://www.boerse-frankfurt.de/bond/de0001102432-deutschland-bundesrepublik-1-25-17-48

Which parts of the code do I need to change depending on the URL I want to retrieve that piece of data from?

Also, how can I retrieve other data, like for example, the date or other fields?

Thank you

Keith Wallace

unread,
Nov 21, 2023, 4:21:39 PM11/21/23
to google-apps-sc...@googlegroups.com
Where’s the StackOverflow link? I’m not seeing the code you’re referencing.


--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/4481d5eb-af5c-41a2-9ab0-8bbc1b5ac793n%40googlegroups.com.

Juan Carlos Gómez

unread,
Nov 22, 2023, 11:16:28 AM11/22/23
to Google Apps Script Community
Hi, sorry thought I had pasted it. It's this one:


Thank you

Juan Carlos Gómez

unread,
Nov 24, 2023, 6:15:55 AM11/24/23
to Google Apps Script Community
Please help when possible, I can't find a solution to import data to my google sheet,

Thank you

Ed Sambuco

unread,
Nov 24, 2023, 4:43:46 PM11/24/23
to google-apps-sc...@googlegroups.com
I don't know what the return is from the second url, you would have to investigate.  But do look at thecontents of the javascript object retired from your older url.  Apparently it embedded a time series of a security proce.  Run the extended script that I attac:

function SAMPLE() {
  const end = Math.floor(new Date().getTime() / 1000);
  const start = end - 3600;
  const url = `https://api.boerse-frankfurt.de/v1/tradingview/lightweight/history/single?from=${start}&to=${end}&symbols=XETR%3AIE00B42NKQ00`;
  const obj = JSON.parse(UrlFetchApp.fetch(url).getContentText())
  console.log(obj[0]);
  const count = obj[0].quotes.count;
  for(i = 0;i < count;i++) {
    var res = obj[0].quotes.timeValuePairs[i];
    console.log(res) // You can check the retrieved value in the log.
  }
}

esamb...@gmail.com

unread,
Nov 26, 2023, 4:42:26 PM11/26/23
to Google Apps Script Community
As an add-on note:  you need to ask the Frankfurt exchange what APIs they do expose for external users.  The second URL in your note is not a uri for an API, but a request to access a stock quote through the browser.
What data you can get and how you get it will be determined by what APIs into the Frankfurt exchange are available.  Maybe they have some kind of listing?
Reply all
Reply to author
Forward
0 new messages