📋 Table of Contents
Why Automated Monitoring?
In competitive markets, prices and offers change daily. Manually visiting 10+ competitor websites every morning is a waste of time and prone to error.
By automating this process, you can:
- React faster: Drop your price immediately when a competitor runs a sale.
- Track historical trends: See if they always discount on Fridays.
- Spot new features: Notice visual changes to their landing pages immediately.
The Strategy
We won't just scrape text (which can be blocked or complex to parse). We will take visual snapshots. This works on any site, regardless of their HTML structure.
We'll write a Python script that:
- Reads a list of competitor URLs.
- Uses SnapAPI to capture a full-page screenshot.
- Saves the image with a timestamp.
- (Optional) Uses OCR or visual comparison to detect changes.
Prerequisites
You'll need Python installed and a SnapAPI key (the free tier works fine). We'll use the
requests library.
pip install requests
The Code
Here is a simple, robust script to get you started.
import requests
import datetime
import os
import time
# Configuration
API_KEY = 'YOUR_SNAPAPI_KEY'
COMPETITORS = {
'competitor_a': 'https://comp-a.com/pricing',
'competitor_b': 'https://comp-b.com/products',
'market_leader': 'https://big-player.com'
}
SAVE_DIR = 'competitor_tracking'
# Ensure save directory exists
if not os.path.exists(SAVE_DIR):
os.makedirs(SAVE_DIR)
def capture_snapshot(name, url):
print(f"Checking {name}...")
timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M")
# Construct API URL
# We use '1280' width for desktop view and 'networkidle0' to ensure prices load
endpoint = "https://snapapi.alterra-solutions.com/v1/screenshot"
params = {
"url": url,
"api_key": API_KEY,
"width": 1280,
"wait_until": "networkidle0",
"response": "binary"
}
try:
response = requests.get(endpoint, params=params)
response.raise_for_status()
filename = f"{SAVE_DIR}/{name}_{timestamp}.png"
with open(filename, 'wb') as f:
f.write(response.content)
print(f"✅ Saved snapshot: {filename}")
except Exception as e:
print(f"❌ Failed to capture {name}: {e}")
# Run the monitor
if __name__ == "__main__":
print(f"Starting generic price monitor at {datetime.datetime.now()}")
for name, url in COMPETITORS.items():
capture_snapshot(name, url)
time.sleep(2) # Be nice to the API
print("Done!")
💡 Pro Tip: Run this script as a CRON job every morning at 9 AM to build a daily archive of your market.
Analyzing the Data
Now that you have these images, what do you do?
1. Quick visual scan: Open the folder in your file explorer (thumbnails view). You can spot red "SALE" banners or layout changes instantly.
2. Automated Diffs: Use a library like Pillow or opencv to
subtract yesterday's image from today's. If the result is not black, something changed.
3. Text Extraction: If you need the exact price number, send the screenshot to an OCR API (like Tesseract) to extract the text data from the pricing pricing table.
Start Tracking Today
Information is power. With less than 50 lines of Python, you can turn a tedious manual chore into an automated intelligence asset.