Prompt
How do I set up automated web scraping for competitor price monitoring?
Latest observation
To set up automated web scraping for competitor price monitoring, you want a pipeline that:
- Identifies the target pages
- Fetches the pages reliably
- Extracts price/product data
- Stores historical snapshots
- Detects changes and alerts you
- Runs on a schedule with monitoring/fail-safes
Here’s a practical setup.
1) Check legality and site rules first
Before scraping:
- Review the site’s Terms of Service
- Check robots.txt
- Avoid personal data and anything sensitive
- Use reasonable request rates
- Prefer APIs or feeds if available
If a competitor provides public product pages, price monitoring is often possible, but you should still be careful about compliance.
2) Choose your approach
Option A: Simple HTML scraping
Use this if:
- Prices are in static HTML
- Pages load without heavy JavaScript
Tools:
- Python
requests BeautifulSouplxml
Option B: Browser automation
Use this if:
- Prices load via JavaScript
- Content is hidden behind interactions
Tools:
Playwright(recommended)Selenium
Option C: Hybrid
Use:
requestsfor fast pagesPlaywrightonly when needed
This is often the best balance.
3) Define the data you want
For each product, decide on fields like:
- Product name
- Competitor name
- Product URL
- Current price
- Sale price
- Currency
- Availability
- SKU / model number
- Timestamp collected
Example data schema:
{
"competitor": "ExampleStore",
"product_name": "Wireless Headphones X100",
"url": "https://example.com/product/x100",
"price": 79.99,
"currency": "USD",
"availability": "In stock",
"scraped_at": "2026-08-18T12:00:00Z"
}
4) Build the scraper
Example with Python + BeautifulSoup
import requests
from bs4 import BeautifulSoup
url = "https://example.com/product/123"
headers = {
"User-Agent": "Mozilla/5.0 (compatible; PriceMonitor/1.0)"
}
resp = requests.get(url, headers=headers, timeout=15)
resp.raise_for_status()
soup = BeautifulSoup(resp.text, "html.parser")
name = soup.select_one("h1.product-title").get_text(strip=True)
price = soup.select_one(".price").get_text(strip=True)
print(name, price)
Example with Playwright for JS-heavy pages
from playwright.sync_api import sync_playwright
url = "https://example.com/product/123"
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
page.goto(url, wait_until="networkidle")
name = page.locator("h1.product-title").inner_text()
price = page.locator(".price").inner_text()
print(name, price)
browser.close()
5) Make it robust
Competitor sites change often, so add:
- Timeouts
- Retry logic
- Error logging
- Selector fallbacks
- Parsing validation
- Rate limiting
- Proxy rotation only if necessary and compliant
Example of retries:
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
import requests
session = requests.Session()
retry = Retry(total=3, backoff_factor=1, status_forcelist=[429, 500, 502, 503, 504])
session.mount("https://", HTTPAdapter(max_retries=retry))
session.mount("http://", HTTPAdapter(max_retries=retry))
6) Store results in a database
Use a database so you can track changes over time.
Good options:
- SQLite for small setups
- PostgreSQL for production
- MySQL if that’s your stack
Suggested tables:
products— target URLs and metadataprice_history— timestamped observationsalerts— notifications triggered
Example price_history columns:
idproduct_idpricecurrencyavailabilityscraped_at
7) Compare new prices against previous values
When a new scrape runs:
- Save current price
- Fetch the previous price
- Detect:
- price drop
- price increase
- out-of-stock status
- new sale/promotion
Example logic:
- Alert if price drops by more than 5%
- Alert if product becomes available again
- Alert if competitor undercuts your price
8) Automate the schedule
Common scheduling options:
- Cron on Linux
- Windows Task Scheduler
- Airflow for larger workflows
- GitHub Actions for lightweight scheduled runs
- Cloud schedulers (AWS EventBridge, GCP Cloud Scheduler)
Cron example:
0 */6 * * * /usr/bin/python3 /path/to/scraper.py
This runs every 6 hours.
9) Add alerts and reporting
Send alerts via:
- Slack
- Microsoft Teams
- SMS
- Dashboard
Example alert conditions:
- Price changed by > 10%
- Item went out of stock
- New competitor product detected
You can generate:
- Daily email summary
- Weekly pricing report
- Live dashboard with charts
10) Use a dashboard for insights
Store the history and visualize:
- Price trends over time
- Lowest competitor price
- Average market price
- Stock status changes
- Frequency of promotions
Tools:
- Metabase
- Grafana
- Superset
- Power BI / Tableau
- Custom web app
11) Handle anti-bot protections carefully
Some sites may use:
- CAPTCHAs
- Rate limits
- Bot detection
- Dynamic rendering
Best practices:
- Keep request volume low
- Use realistic intervals
- Respect robots.txt
- Cache responses where possible
- Prefer official data sources
- Avoid bypassing protections in ways that violate terms
If a site is heavily protected, it may be better to use:
- a third-party price intelligence provider
- affiliate feeds
- marketplace APIs
- manual review for critical targets
12) Production architecture suggestion
A simple production stack:
- Scraper service: Python worker
- Scheduler: cron/Airflow
- Storage: PostgreSQL
- Queue: Redis + Celery if many URLs
- Monitoring: logs + alerts
- Dashboard: Metabase/Grafana
Workflow:
- Scheduler triggers job
- Worker fetches product pages
- Parser extracts price and availability
- Data saved to DB
- Change detection runs
- Alerts sent if needed
13) Example file structure
price-monitor/
scraper/
__init__.py
fetch.py
parse.py
db.py
alerts.py
configs/
competitors.yaml
main.py
requirements.txt
14) Recommended libraries
requestsbeautifulsoup4lxmlplaywrightpandassqlalchemypsycopg2-binaryorsqlite3tenacityfor retriesapscheduleror cronslack_sdk/ SMTP for alerts
15) Start small, then scale
Begin with:
- 5–10 competitor product URLs
- One scraper
- SQLite/PostgreSQL
- Daily schedule
Then expand to:
- hundreds/thousands of URLs
- product matching logic
- alerts and dashboard
- distributed workers
If you want, I can help you with one of these next:
- a Python scraper template
- a Playwright-based scraper
- a database schema for price history
- a full end-to-end architecture
- a working example for a specific competitor site structure
Observation history
See 4 earlier observations
Create a free Obsurfable account to unlock historical responses, model comparisons, and deeper brand intelligence.
How did Obsurfable measure this prompt?
Obsurfable records AI answers to buyer-style prompts in its research corpus (5 observations for this page). Metrics are distributions over observations, not a single static ranking.
Which AI systems does Obsurfable collect answers from?
OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, and Meta AI.