Using this Google App Script to get cryptocurrency prices from coinmarketcap: ( credit for this script goes to Josh Bradley via this stackoverflow topic: To exceed the ImportXML limit on Google Spreadsheet )
function importRegex(url, regexInput) {
var output = '';
var fetchedUrl = UrlFetchApp.fetch(url, {muteHttpExceptions: true});
if (fetchedUrl) {
var html = fetchedUrl.getContentText();
if (html.length && regexInput.length) {
output = html.match(new RegExp(regexInput, 'i'))[1];
}
}
// Grace period to not overload
Utilities.sleep(1000);
return output;
}
in the cell that I want to paste the price, I use:
=importRegex("https://coinmarketcap.com/currencies/cosmos", "<div class=.priceValue___11gHJ.>(.*)<\/div>")
But instead of the price, I get the price plus a lot of junk at the end.
$14.18</div><span ... (lots of stuff after)
Why isn't the regex working? Thank you!