Skip to content

Instantly share code, notes, and snippets.

@nmaruy27
Last active January 18, 2024 12:17
Show Gist options
  • Save nmaruy27/679a47ad6ae07245f957d7d026e8f5d7 to your computer and use it in GitHub Desktop.
Save nmaruy27/679a47ad6ae07245f957d7d026e8f5d7 to your computer and use it in GitHub Desktop.
function getStockValue(stockCode) {
var code = String(stockCode).split(',')[0];
var url = 'https://xxxxxx.com/';
var res = UrlFetchApp.fetch(url + code);
if(res.getResponseCode() == 200) {
var value = Parser.data(res.getContentText()).from('<div class="stock_price">').to('<span class="decimal">').build();
return value.trim().replace('.', '');
} else {
return '取得失敗';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment