A simple CLI tool to watch a web page for changes.
Project description
WebWatch
WebWatch is a simple command-line tool to monitor a web page or a specific part of it for changes. When a change is detected, it raises an alert on the console and can optionally send an email notification.
Features
- Watch any URL.
- Target specific content using CSS selectors or XPath expressions.
- Configurable check interval.
- Console and email notifications.
- Built with modern Python tools: click, httpx, loguru, and lxml.
Installation
This project uses uv for package and virtual environment management.
-
Install uv: Follow the official instructions to install uv:
# Example for Linux/macOS curl -LsSf https://astral.sh/uv/install.sh | sh
-
Create a virtual environment and install webwatch: Clone this repository, then run:
git clone https://example.com/webwatch.git cd webwatch uv venv source .venv/bin/activate uv pip install -e .
Usage
The basic command requires a single URL argument.
webwatch <URL> [OPTIONS]
Examples
-
Watch a page for any change in the every 30 seconds:
webwatch https://example.com --period 30
-
Watch the element with ID main-content:
webwatch https://example.com --css "#main-content"
-
Watch the first
tag on a page using XPath:
webwatch https://example.com --xpath "/html/body/div/h1"
-
Send an email notification on change:
webwatch https://example.com --css ".price" --email "your.email@example.com"
-
watch an online clock to see if it changes:
webwatch https://dayspedia.com/time/online/ --xpath /html/body/div[1]/main/section[1]/div[1]/div[2]
Tip: You can use the developper tools in your browser to inspect elements and find their CSS selectors or XPath expressions.
Command-line Options
| Argument / Option | Description | Default |
|---|---|---|
| URL (required) | The URL of the web page to watch. | - |
| --p, --period | Time period in seconds to check for changes. | 60 |
| --css | CSS selector to target a specific part of the page. | - |
| --xpath | XPath expression to target a specific part of the page. | //body |
| Email address to send notifications to on change. | ||
| --v, --version | Show the version and exit. | - |
| -h, --help | Show the help message and exit. | - |
Email Notification Setup
To receive email notifications, you must configure your SMTP server settings using environment variables:
export SMTP_SERVER="smtp.example.com"
export SMTP_PORT="587" # Or 465 for SMTP_SSL
export SMTP_USER="your-username"
export SMTP_PASSWORD="your-password"
export SMTP_FROM_EMAIL="sender@example.com"
UsageProject Structure
.
├── .gitlab-ci.yml # GitLab CI/CD pipeline configuration
├── LICENSE # MIT License file
├── pyproject.toml # Project metadata and dependencies
├── README.md # This file
├── src
│ └── webwatch
│ ├── __init__.py
│ ├── cli.py # Command-line interface logic (click)
│ ├── watcher.py # Core logic for watching and comparing
│ └── notifications.py # Notification handling
└── tests
└── test_watcher.py # Unit tests for the watcher
Development and Contribution
We welcome contributions! Please follow these steps to contribute.
Setting up the Development Environment
-
Install development dependencies, including
pytestandruff:uv pip install -e ".[dev]" # Note: You need to define a [project.optional-dependencies] table in pyproject.toml for this. # For now, install them manually: uv pip install pytest pytest-httpx ruff
-
Run formatting and linting: This project uses
rufffor code formatting and linting.# Check formatting ruff format --check . # Apply formatting ruff format . # Check for linting errors ruff check .
-
Run tests: Tests are written with pytest.
pytest
Contribution Guidelines
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes, ensuring you add or update tests as appropriate.
- Ensure all checks (linting and tests) pass.
- Submit a pull request with a clear description of your changes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file webwatch-0.1.0.tar.gz.
File metadata
- Download URL: webwatch-0.1.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6a66fabdf03d16fb96534197a952c829ce31c47cd65e251e96d3636bc1b6554
|
|
| MD5 |
fd3941907e31c883dcf28e11d02305f0
|
|
| BLAKE2b-256 |
963b7ee5eb80d9eeb767ec440c16de834320c38ca1bdc9d97ddb6b9dc41783fa
|
File details
Details for the file webwatch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: webwatch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de34d5261a27e75cab8af9f7befc229fbc755bc4fa612949aef640dd1ea8b473
|
|
| MD5 |
ed71c3a8c1b44370204ff5b9de0923f4
|
|
| BLAKE2b-256 |
be2e90ed63cc0f8bc8edb636986034c9b2b5416718c8cdc92a408acca7d57311
|