urlwatch Documentation

repository·master·Indexed 23 days ago

https://github.com/thp/urlwatch

urlwatch 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.

Tokens
22.5K
Snippets
85
Records
174
Agent score
80%

What's inside urlwatch

  1. Overview of urlwatch

    master
    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.
  2. Manage urlwatch jobs via urls.yaml

    master

    Jobs are the units of monitoring in urlwatch. They are defined in the urls.yaml configuration file.

    • Use urlwatch --edit to open the configuration file for editing.
    • Use urlwatch --list to see a list of all jobs and their automatically assigned index numbers.

    It is recommended to provide a name for each job for better readability:

    name: "This is a human-readable name/label of the job"
    urlwatch --edit
    urlwatch --list
  3. Configure XMPP notifications

    master

    You 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-login
  4. Monitor the same URL in multiple jobs

    master

    urlwatch uses the url (for URL/Browser jobs) or navigate (for Browser jobs) and command (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"
  5. Configure E-Mail via Amazon SES

    master

    To 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 page
  6. Send HTML form data using POST

    master

    To simulate an HTML form submission, provide the form fields in the data field of the job description. By default, urlwatch uses the HTTP POST method and sets the Content-type to application/x-www-form-urlencoded.

    name: "My POST Job"
    url: http://example.com/foo
    data:
      username: "foo"
      password: "bar"
      submit: "Send query"
  7. Test a reporter configuration

    master

    You can verify if a reporter is correctly configured by using the --test-reporter command-line option followed by the reporter name. This generates a test report containing new, changed, unchanged, and error notifications.

    To test the stdout reporter:

    urlwatch --test-reporter stdout

    To test an email reporter:

    urlwatch --test-reporter email

    If notifications fail, use the --verbose flag to view detailed debug logs.

    urlwatch --test-reporter stdout
  8. Send arbitrary data using HTTP PUT

    master

    You can customize the HTTP method and Content-type header to send arbitrary requests (like PUT) by using the method and headers keys.

    name: "My PUT Request"
    url: http://example.com/item/new
    method: PUT
    headers:
      Content-type: application/json
    data: '{"foo": true}'
  9. Configure urlwatch jobs and filters

    master

    Jobs 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 --edit command, which performs sanity checks on your YAML before activating it.

    If the editor fails to open, ensure your $EDITOR or $VISUAL environment 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 filter key to apply one or more filters to the retrieved data. Filters can be chained to transform data (e.g., extracting HTML with xpath, converting to text with html2text, and searching with grep).

    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:
    ---