Prompt

How do I automate recurring web scraping jobs?

Latest observation

Jul 15, 2026 · OpenAI APIWeb search: off

To automate recurring web scraping jobs, you generally need four pieces:

  1. The scraper — code that collects the data
  2. A schedule — something that runs it periodically
  3. Storage/output — where the results go
  4. Monitoring/error handling — so you know when it breaks

Common ways to schedule it

1. Cron / system scheduler

Best for simple setups.

  • Linux/macOS: use cron
  • Windows: use Task Scheduler

Example cron entry to run every day at 2 AM:

0 2 * * * /usr/bin/python3 /path/to/scraper.py >> /path/to/log.txt 2>&1

2. Cloud schedulers

Good if you want it running without managing a server.

  • AWS EventBridge + Lambda/EC2/ECS
  • Google Cloud Scheduler + Cloud Run/Functions
  • Azure Scheduler / Functions
  • GitHub Actions on a schedule for lightweight jobs

Example GitHub Actions schedule:

name: Run scraper

on:
  schedule:
    - cron: "0 2 * * *"
  workflow_dispatch:

jobs:
  scrape:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"
      - run: pip install -r requirements.txt
      - run: python scraper.py

3. Workflow/orchestration tools

Best if your scraping is part of a bigger pipeline.

  • Airflow
  • Prefect
  • Dagster
  • Luigi

These are useful if you need retries, dependencies, logging, and multiple scraping jobs.

Typical automation setup

A solid pattern is:

  • scrape data
  • save raw HTML/JSON for debugging
  • transform/clean the data
  • write to a database or file
  • send alerts if scraping fails

Good practices

Add retries and timeouts

Web scraping often fails intermittently.

  • Set request timeouts
  • Retry on temporary failures
  • Respect rate limits

Log everything

Log:

  • start/end time
  • URLs scraped
  • success/failure
  • number of records extracted

Detect changes in page structure

Websites often change HTML. Consider:

  • validating expected fields
  • alerting when elements are missing
  • keeping sample test pages

Avoid overloading sites

Use:

  • delays between requests
  • reasonable concurrency
  • user-agent headers
  • robots.txt awareness where appropriate

Save incremental results

If scraping recurring data:

  • only fetch new items
  • deduplicate by ID/date/url
  • store last-run timestamp

Example simple Python pattern

import requests
from bs4 import BeautifulSoup
from datetime import datetime

def scrape():
    url = "https://example.com"
    r = requests.get(url, timeout=15)
    r.raise_for_status()

    soup = BeautifulSoup(r.text, "html.parser")
    title = soup.find("title").get_text(strip=True)

    with open("output.csv", "a", encoding="utf-8") as f:
        f.write(f"{datetime.utcnow().isoformat()},{title}\n")

if __name__ == "__main__":
    scrape()

Then schedule it with cron, Task Scheduler, or a cloud scheduler.

If the site uses JavaScript

Use a browser automation tool such as:

  • Playwright
  • Selenium

Playwright is usually the better choice for new projects.

Recommended approach by scale

  • 1 small job: cron + Python script
  • several jobs: GitHub Actions or cloud scheduler
  • complex pipeline: Airflow/Prefect/Dagster
  • heavy JS sites: Playwright + scheduler

If you want, I can show you:

  • a cron setup
  • a GitHub Actions scraper workflow
  • or a Python example with logging and retries

Observation history

Unlock observation history

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 (1 observation 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.