Scenario:
I am trying to use Google spreadsheet to do something like this:
I've a set of Blog URL's (more than 50) for which I want to fetch title
Currently I am using the formula: ImportXML(A2,"//h1[#class='entry-title']" )
The Problem w/ this approach is that ImportXML calls are limited to 50 per spreadsheet and I've more than 50.
I browsed/searched - found out that we can use ImportXML calls in google apps script but did not found any example.
I found this: https://developers.google.com/apps-script/articles/XML_tutorial but I was hoping to use ImportXML function.
Can anyone describe or point to a resource where they have used ImportXML in a google apps script? Thanks!
I would use a few spreadsheets, then pull the results together into a master spreadsheet, or are you doing >1000 or so. If you have lots, the XML_tutorial link you have is the place to start.
But last time I checked, google-apps-script does not support google spreadsheet functions, if I remember, the feature request to support all spreadsheet functions in GAS was rejected.
Related
I have a google sheets which is linked to a form and a google scripts that was created in the menu of google sheets. This script runs fine and I use it to format the data. However, I have another script which I created from the google developer console, which sends and receives data from a website. I need this second script to get the value of a cell in the google sheets.
How can I link this second form to the google sheets while keeping the script already linked to the sheets?
When looking at responses to other questions they seem to be about individual sheets in a set so just to clarify, when referring to google sheets I mean the whole google sheets document. I only have one sheet anyways.
If it helps: The script I want to add acts a bit like a server and is being deployed by google scripts while the script that is already linked is only run when I call it on the sheets.
There is not way of attaching a standalone script to a document making it a bound script (which is the actual terminology for the script linked the the document).
The simplest way would be to copy-paste the code to the other script. You can deploy the bounded script.
If you really need more than one project for whatever reason, you can enable the Apps Script API and use projects.create (read reference) to create another one. If you don't know what this means, you probably shouldn't use it as it's finicky at best.
I found a solution which was to link the script to the google sheets using
var ss = SpreadsheetApp.openById("SHEET_ID_HERE");
I can then use ss.getActiveSheet().getRange().getValue();
and other funtions.
Thanks for the help!
In Sheets I have dates and events that I would like to publish in Docs with the events listed under MONTH - YEAR. The number of events can vary, though usually over 400 events over a 2 year period. Sheets has them all sorted, but I haven't programmed in JavaScript before as I have used Access to do this in the past (But it seems to be overkill to have Access just for this.) It seems that Google App Script is the only way to do it?
A sample of the Sheet is here https://docs.google.com/spreadsheets/d/1IYmdIZU9wEVgSr7l4UWzJE7xXgUEQQOHUVarBHCeWgI/edit?usp=sharing
A sample of the doc that I would like to make is here https://docs.google.com/document/d/1obF-OiRAQG_6WxwiCT5-GkvnjETsdYiMHB2SDGxDeKA/edit?usp=sharing
From the question
It seems that Google App Script is the only way to do it?
Besides Google Apps Script, there are APIs for Google Sheets and Google Docs that you could use with several programming languages. For more details see
https://developers.google.com/docs
https://developers.google.com/sheets
I want to write a Google Apps Script to generate a list of the IDs of the scripts bound to certain spreadsheets.
I cannot find a way to programmatically, via GAS, get the ID of a bound script.
If I have a spreadsheet object, I have methods like getId to get the ID of the spreadsheet, but not the bounded script.
Using the DriveApp, I can find standalone scripts using DriveApp.getFilesByType('application/vnd.google-apps.script') but not bound ones!
Any suggestions?
Unfortunately (by my own research) this is not currently possible. I have been wanting to programatically identify and access bound scripts for several years, I look into it periodically, I've always come up empty handed.
Haven't found any Google documentation explicitly on the topic, still hoping this hole gets filled eventually.
I am creating a spreadsheet portfolio. I came across some limitation, e. g. that I can not automate the process of importing the data from a website for different stocks. This is since the Index for the stock information on the website is often different from another stock. However there is the pattern that it is the next Index from a defined string e. g. "Branche". This made me wonder if I can automate the process with the Google Apps Script.
I wrote down the steps at first in Google Sheets. Then I formulated the steps in the Google Apps Script. Now I am stuck.
Step 1
=IMPORTXML("https://www.comdirect.de/inf/aktien/detail/uebersicht.html?ID_NOTATION=9386126";"//tr/td[#class='simple-table__cell']")
Step 2
=IMPORTXML(CONCATENATE("https://www.comdirect.de/inf/aktien/detail/uebersicht.html?ID_NOTATION=";"9386126");"//tr/td[#class='simple-table__cell']")
Step 3
=INDEX(IMPORTXML(CONCATENATE("https://www.comdirect.de/inf/aktien/detail/uebersicht.html?ID_NOTATION=";"9386126");"//tr/td[#class='simple-table__cell']");62;1)
Step 4 final product - just an idea not working yet
function import_branche() {
var url1 = "https://www.comdirect.de/inf/aktien/detail/uebersicht.html?ID_NOTATION="
var ulr2
var ticker = "//tr/td[#class='simple-table__cell']"
Index = find the INDEX with the String == "Branche"
return Index(IMPORTXML(CONCATENATE(url1;url2); ticker);(Index+1);1)
}
Ideally, I would like to have a function where I only need insert the link of the website and get the result. Here is the index for the information automatically found.
Google Apps Script can't execute Google Sheets spreadsheet functions like IMPORTXML, so you have two basic alternatives
Use Google Apps Script to get the result of a IMPORTXML formula from the spreadsheet, then use JavaScript to do the rest of the job
Do the job completely using Google Apps Script and JavaScript
Related
Google docs ImportXML called from script
(javascript / google scripts) How to get the title of a page encoded with iso-8859-1 so that the title will display correctly in my utf-8 website?
I'm using google spreadsheet with Google Apps Script.
but it gives me error message too easily. like this
Error
Script invoked too many times per second for this Google user account. (line 0).
Is there any way to avoid the error? (except the way reduce function call)
or alternative Spreadsheet program that support Javascript function define?
As noted in the documentation you can work around this by ensuring that your function supports ranges, and the function on a range. See also the section on Optimization on the Custom Functions in Google Sheets page.
To create a custom function you should use Google Apps Script, it's the only way. Regarding the way to avoid the error, there are several things that could be done but to be certain about what is required in your case you should add more details.