urlwatch Documentation
repository·master·Indexed 23 days ago
https://github.com/thp/urlwatchurlwatch is a web monitoring tool that tracks changes on webpages and provides notifications via email, terminal, or third-party services, including unified diffs of the changes. It supports various job types including URL, browser (via Playwright), and shell jobs, with advanced features for filtering diff output, handling HTTP POST/PUT requests, and configuring custom diff tools.
What's inside urlwatch
- urlwatch is a tool designed to monitor webpages for changes. When a change is detected, it notifies you via email, terminal output, or various third-party services. Notifications include the URL that changed and a unified diff showing exactly what was modified.
Manage urlwatch jobs via urls.yaml
masterJobs are the units of monitoring in
urlwatch. They are defined in theurls.yamlconfiguration file.- Use
urlwatch --editto open the configuration file for editing. - Use
urlwatch --listto see a list of all jobs and their automatically assigned index numbers.
It is recommended to provide a
namefor each job for better readability:name: "This is a human-readable name/label of the job"urlwatch --edit urlwatch --list- Use
Run a subset of specific jobs
masterInstead of running all jobs, you can execute specific jobs by providing their index numbers as arguments to theurlwatchcommand.Configure XMPP notifications
masterYou can send notifications via the XMPP protocol. It is recommended to register a dedicated XMPP account for
urlwatch.Configure the reporter as follows:
report: xmpp: enabled: true sender: "BOT_ACCOUNT_NAME" recipient: "YOUR_ACCOUNT_NAME"To securely store your XMPP password in the keychain, run:
urlwatch --xmpp-loginInstall optional packages for urlwatch features
masterAdditional features in
urlwatch(like specific reporters, filters, or job kinds) require optional Python packages. Install the required package(s) usingpipbased on the feature you want to use.python3 -m pip install <packagename>Monitor the same URL in multiple jobs
masterurlwatch uses the
url(for URL/Browser jobs) ornavigate(for Browser jobs) andcommand(for Shell jobs) keys as unique identifiers. To monitor the same URL multiple times, you must make the identifier unique by appending a fragment (e.g.,#1,#2) to the URL.name: "Looking for Thing A" url: http://example.com/#1 filter: - grep: "Thing A" --- name: "Looking for Thing B" url: http://example.com/#2 filter: - grep: "Thing B"Install or upgrade urlwatch with pip
masterYou can install urlwatch for the first time or upgrade an existing installation using
pip. It is recommended to usepython -m pipto ensure you are targeting the correct Python environment.python -m pip install --upgrade urlwatchConfigure E-Mail via Amazon SES
masterTo use Amazon Simple Email Service (SES), use the SMTP configuration method. Replace the GMail host with your SES SMTP endpoint (e.g.,
email-smtp.us-west-2.amazonaws.com) and use the credentials and port provided by your SES settings.report: email: enabled: true from: your-verified-ses-email@example.com to: destination@example.com method: smtp smtp: host: email-smtp.us-west-2.amazonaws.com auth: true port: 465 # Use settings from your SES login pageSend HTML form data using POST
masterTo simulate an HTML form submission, provide the form fields in the
datafield of the job description. By default, urlwatch uses the HTTPPOSTmethod and sets theContent-typetoapplication/x-www-form-urlencoded.name: "My POST Job" url: http://example.com/foo data: username: "foo" password: "bar" submit: "Send query"Test a reporter configuration
masterYou can verify if a reporter is correctly configured by using the
--test-reportercommand-line option followed by the reporter name. This generates a test report containingnew,changed,unchanged, anderrornotifications.To test the
stdoutreporter:urlwatch --test-reporter stdoutTo test an
emailreporter:urlwatch --test-reporter emailIf notifications fail, use the
--verboseflag to view detailed debug logs.urlwatch --test-reporter stdoutSend arbitrary data using HTTP PUT
masterYou can customize the HTTP method and
Content-typeheader to send arbitrary requests (likePUT) by using themethodandheaderskeys.name: "My PUT Request" url: http://example.com/item/new method: PUT headers: Content-type: application/json data: '{"foo": true}'Configure urlwatch jobs and filters
masterJobs are defined in a YAML configuration file. Each job represents a website or shell command to be monitored. You can edit this configuration using the
urlwatch --editcommand, which performs sanity checks on your YAML before activating it.If the editor fails to open, ensure your
$EDITORor$VISUALenvironment variable is set.Job Types: Every job must include exactly one of the following keys:
url: Retrieves content via HTTP GET (default).navigate: Uses a headless browser to load pages requiring JavaScript.command: Runs a shell command.
Filters: You can use the
filterkey to apply one or more filters to the retrieved data. Filters can be chained to transform data (e.g., extracting HTML withxpath, converting to text withhtml2text, and searching withgrep).export EDITOR=/bin/nano urlwatch --edit # Example job definition in YAML name: "Sample urlwatch job definition" url: "https://example.dummy/" https_proxy: "http://dummy.proxy/" max_tries: 2 filter: - xpath: '//section[@role="main"]' - html2text: method: pyhtml2text unicode_snob: true body_width: 0 inline_links: false ignore_links: true ignore_images: true pad_tables: false single_line_break: true - grep: "lines I care about" - sort: ---