I've tried to get importxml into a function so that I can get a specific piece of info from a website, but the result I get is the formula not the result of the formula/function, here is my script, sorry I'm new a scripting very new. BTW if I copy and paste the value gotten from the function then I get what I'm looking for but have to "activate" the formula by adding and taking a character
function fveps2(ticker) {
var url = `https://finviz.com/quote.ashx?t=${ticker}`;
var Xpath_1 = '/html/body/div[4]/div/table[2]/tbody/tr[1]/td[4]';
var importXpath_1 = '=IMPORTXML("' + url + '","'+ Xpath_1 + '")';
return importXpath_1;
}
and the result of this script is:
=IMPORTXML("https://finviz.com/quote.ashx?t=","/html/body/div[4]/div/table[2]/tbody/tr[1]/td[4]")
rather than the above I would like to get the value of such function, so by creating a function makes it easier to call (fveps2) and get the value of such rather, than write importxml(....etc every time, therefore I can easily use my function and change the xpath to get the desired value from the source url
thanks in advance! Alex