Skip to main content

Overview

Monitoring competitor pricing and inventory across multiple e-commerce sites is a common but tedious task. Manual checks don’t scale, and scraping scripts break every time a site redesigns. Refrain lets you describe what data to collect, generates a self-healing runbook, and runs it on a schedule. When a site’s layout changes, the runbook adapts automatically.

Example runbook

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 }}"

Generate and execute

1

Generate the runbook

npx @refrainai/cli generate -- \
  --url https://shop.example.com/products/sample \
  --goal "Extract the current price and stock status" \
  --context ./context.md \
  --output ./price-check.yaml
2

Prepare a product list

Create a CSV with the URLs to monitor:
product_url
https://shop.example.com/products/001
https://shop.example.com/products/002
https://shop.example.com/products/003
3

Batch execute

npx @refrainai/cli execute -- \
  --runbook ./price-check.yaml \
  --data ./products.csv \
  --output-dir ./reports

Why this works well

  • Batch execution — Monitor hundreds of products from a single CSV file.
  • Self-healing — Site redesigns don’t require script rewrites.
  • Scheduled runs — Set up daily or hourly checks via the Web Console scheduler.
  • Slack alerts — Get notified when prices drop or items go out of stock.

What’s next