Skip to content

Instantly share code, notes, and snippets.

@purintai
Last active February 20, 2017 06:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save purintai/29f759dd07f59840e392 to your computer and use it in GitHub Desktop.
Save purintai/29f759dd07f59840e392 to your computer and use it in GitHub Desktop.
価格.comのitemページから値段取得して返すだけの関数
// Only for Google Scripts
function kakakucomPrice(itemUrl) {
try {
var response = UrlFetchApp.fetch(itemUrl);
if (response.getResponseCode() == 200) {
var html = response.getContentText();
re = /ecomm_totalvalue: \'(\d+)\'/;
var result = html.match(re);
if (result == null) {
return "Sold out";
} else {
return parseInt(result[1]);
}
} else {
return "Error";
}
} catch(e) {
Logger.log(e);
return "Error";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment