LoginSignup
27
30

More than 5 years have passed since last update.

GoogleスプレッドシートでAmazon特定商品の価格を定期的に取得

Posted at

Google Apps Scriptを用いて、Googleスプレッドシート上に、定期的にAmazonの特定商品の価格を取得・追加していきます。下記の記事内容をまとめなおしたものです。

スクリプト

getAmazonPrice.gs
function getAmazonPrice() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var date = new Date();
  var row = sheet.getLastRow()+1;

  sheet.getRange('A'+ row).setValue(date);

  sheet.getRange('B'+ row)
    .setFormula('=IMPORTXML(E1,"//td[@class=\'a-span12\']/span[@class=\'a-size-medium a-color-price\']")');
}

使い方

  1. 上図のようなスプレッドシートを作成
  2. E2セルに任意のAmazonページURLを入力
  3. スクリプトエディタに上記「getAmazonPrice.gs」を貼り付け
  4. 任意のスパンでトリガーを設定
27
30
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
30