Google Sheets Import XML text value will not display - html

I'm trying to import some energy data into a Google Sheet, but can't seem to get the value to appear since it is just text in the HTML line, and shows up as --,--- in the output. I have tried adding /text() to the XPath but that is still not working either.
Website with data to import:
http://www.caiso.com/TodaysOutlook/Pages/default.aspx
Formula in Google Sheets:
=IMPORTXML("http://www.caiso.com/TodaysOutlook/Pages/default.aspx","//div[#class='overview-large-number']")
Also tried the follwoing Xpath with the same --,--- being displayed.
/html/body/div[2]/div[3]/div[4]/div/div/div[2]/div/div[1]/div[1]/div[1]
/html/body/div[2]/div[3]/div[4]/div/div/div[2]/div/div[1]/div[1]/div[1]/text()
Screen Shot of Webpage:
Caiso Webage with Data
HTML Element with Data:
<div class="overview-large-number">41,946 <span>MW</span></div>
Screen Shote of Google Sheets current Output:
Google Sheets Screenshot
Thank you in advanced for any insight.

The data is populated after the page loads, so you can't use ImportXML(). The data is requested via HTTP Get on the URL http://www.caiso.com/outlook/SP/stats.txt and is returned in JSON format.
Get the ImportJSON script from here and add it to your sheet (Tools > Script Editor).
This should be enough to get you started:
=Transpose(ArrayFormula(HLOOKUP(
{"AvailableCapacity","CurrentSystemDemand","todayForecastPeakDemand","histDemand","TodaysPeakDemand","tomorrowsForecastPeakDemand"},
ImportJSON("http://www.caiso.com/outlook/SP/stats.txt"),2,0)))
Note that the Historical Peak value is already a string, so you may have to do some extra work to get the number out.

Related

Importxml and importhtml don´t give me the data from the table in website that I need (only headers)

I´m trying to take information from a website to googlesheets and I tried with importxml and importhtml, but it´s not working.
https://www.fpf.pt/pt/Jogadores/Ficha-de-Jogador/playerId/1871569
First I tried with Importhtml, only appear the headers:
=IMPORTHTML(A1;"table";1)
A1:
https://www.fpf.pt/pt/Jogadores/Ficha-de-Jogador/playerId/1871569
Result from formula (No Data):
Época Clube Modalidade Escalão
{{item.Season}} {{item.Name}}{{item.Name}} {{item.SportTypeName}} {{item.FootballClassName}}
Then I tried with importxml to appear one column only:
/html/body/form/div[3]/div/div[3]/div[5]/div[1]/div/div/div/div/div[2]/div/section/div/article/div/div/div[2]/div/div/div/table/tbody/tr[1]/td[1]
Result from formula (No data):
{{item.Season}}
Could anyone help me understand what i´m doing wrong?
Thank You Very Much
you will need to find another site with intel you attempting to scrape. the empty table is the result of google sheets not supporting the import of JavaScript elements. you can always check for compatibility by disabling JS in site settings and only what's left can be usually scrapped. in this case its nothing:

IMPORTHTML() doesn't work in this webpage

I want to import data from a table from the following page:
https://basketballmonster.com/playerrankings.aspx
When I do so, with all players filter selected, only the top players are imported to my googlesheet. Can someone help me achieve this? Appreciation in advance.
I attached the googlesheet below for your review:
https://docs.google.com/spreadsheets/d/1uvhNp6gBnnEvs8CBb4K7onccew_doFp96wmFEsYyLBk/edit?usp=sharing
Google Sheets can't know what your browser has, so it doesn't know whether you selected which filter. You have to get the same html for Sheets that you have displayed in your browser, which means adding the filter in your query.
Since it looks like the controls aren't passed as parameters in a GET request, sadly it's not as simple as appending
?PlayerFilterControl=TopPlayers to the url.
You have to POST it as a payload with a post request like
{ 'PlayerFilterControl': 'AllPlayers'}.
Sadly Google Sheets IMPORTHTML() doesn't support post request yet, so you'll have to get into apps scripts, request and xml parsing.
I suggest you check out these:
https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app
https://developers.google.com/apps-script/reference/xml-service

How do I import a live value from website to google sheet?

The website link is as below: https://tracker.axie.management/ronin:4f850f91b6d87f47d8e15e0bd63b330d20e862fe/overview
The full xpath of the element I want is as below:
/html/body/div[2]/div[1]/div/div[2]/div[1]/div/div/div[1]/div[1]/div/div[2]/div[1]/h2/div/span
Does anyone know how do I import this value to my google sheet ?
No way. The content is added dynamically (by using Javascript), it can't be imported by using Google Sheets built-in functions. https://webapps.stackexchange.com/questions/115664/how-to-know-if-google-sheets-importdata-importfeed-importhtml-or-importxml-fun.
May be your data in included in this js file : https://tracker.axie.management/static/js/main.e40acdab.chunk.js

replace text in links with function with input parametr URL

I have a problem with this algorithm in Google Doc script :
I need to go through all the links in Google Doc
get its URL for each link
call the function called "getTextByURL (URL)" with the URL input parameter
and update the displayed link text with the return value of this function.
Used to C#, VBA and Word model, where there is a collection of Hyperlinks,
I have a problem in Google Doc script with this algorithm.
Can anyone advise me?
Thanks, Ilya.

email google spreadsheet as html

I am trying to create a google script that emails out a spreadsheet as html. I am trying to convert the spreadsheet to html using the export url, but currently google docs only lets you export it out as a zip. Is there a way to get the html representation of a spreadsheet worksheet?
function getDocAsHtml(docId){
var url="https://docs.google.com/spreadsheets/d/" + docId + "/exportFormat?format=html";
var fetch=UrlFetchApp.fetch(url+docId).get
return fetch;
}
Publish the sheet that you want to get the HTML out of:
File Menu, PUBLISH TO WEB
Make sure that: "Automatically Republish When Changes Are Made" is checked.
Get the URL of the published page. Use that URL in a UrlFetchApp.fetch() request.
Use UrlFetchApp to get the content of that published sheet.
function fncSheetToHTML() {
var theSheetContents = UrlFetchApp.fetch("https://docs.google.com/spreadsheets/d/YourID_Here/pubhtml?gid=123abc&single=true");
Logger.log("theSheetContents: " + theSheetContents);
}
The returned contents is a string. If you view the LOGS of what is returned from the above code, you'll see HTML tags in the content.
The published sheet is visible to anyone who uses that URL. So, if you don't want people to see the contents, this method might not be what you want. If you don't share that published URL, I don't know how likely it is that anyone will ever find it.