Last active
February 20, 2017 06:34
-
-
Save purintai/29f759dd07f59840e392 to your computer and use it in GitHub Desktop.
価格.comのitemページから値段取得して返すだけの関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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