> ## Documentation Index
> Fetch the complete documentation index at: https://docs.therefrain.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# EC 価格・在庫監視

> 競合 EC サイトの価格変動や在庫状況を定期チェックし、変動があれば即座に通知。

## 概要

競合の EC サイトで価格や在庫を手動でチェックするのは時間がかかり、スケールしません。スクレイピングスクリプトはサイトのリニューアルのたびに壊れます。

Refrain なら、取得したいデータを伝えるだけで自己修復する手順書を生成し、スケジュール実行できます。サイトのレイアウトが変わっても手順書が自動的に適応します。

## 手順書の例

```yaml theme={null}
name: competitor-price-check
url: https://shop.example.com/products
variables:
  - name: product_url
    source: data
steps:
  - action: navigate
    url: "{{ product_url }}"
  - action: wait
    selector: ".product-detail"
  - action: extract
    selector: ".price-current"
    capture: price
  - action: extract
    selector: ".stock-status"
    capture: stock
  - action: export
    format: csv
    fields:
      - name: url
        value: "{{ product_url }}"
      - name: price
        value: "{{ price }}"
      - name: stock
        value: "{{ stock }}"
```

## 生成と実行

<Steps>
  <Step title="手順書を生成する">
    ```bash theme={null}
    npx @refrainai/cli generate -- \
      --url https://shop.example.com/products/sample \
      --goal "現在の価格と在庫状況を取得する" \
      --context ./context.md \
      --output ./price-check.yaml
    ```
  </Step>

  <Step title="商品リストを準備する">
    監視対象の URL を CSV にまとめます：

    ```csv theme={null}
    product_url
    https://shop.example.com/products/001
    https://shop.example.com/products/002
    https://shop.example.com/products/003
    ```
  </Step>

  <Step title="バッチ実行する">
    ```bash theme={null}
    npx @refrainai/cli execute -- \
      --runbook ./price-check.yaml \
      --data ./products.csv \
      --output-dir ./reports
    ```
  </Step>
</Steps>

## Refrain が向いている理由

* **バッチ実行** — CSV 1 ファイルで数百商品を一括監視。
* **自己修復** — サイトリニューアルでもスクリプトの書き直し不要。
* **スケジュール実行** — Web コンソールのスケジューラーで毎日・毎時の定期チェック。
* **Slack 通知** — 価格変動や在庫切れを即座に通知。

## 次のステップ

<CardGroup cols={2}>
  <Card title="手順書を実行する" icon="play" href="/ja/guides/execute-runbook">
    CSV データを使ったバッチ実行を学ぶ。
  </Card>

  <Card title="承認と通知" icon="bell" href="/ja/guides/approval-and-notifications">
    価格変動時の Slack 通知を設定する。
  </Card>
</CardGroup>
