Attenzione cover blog photo

Attenzione

Attenzione - A Symfony command-line application that monitors web pages for specific HTML elements and sends notifications when they're found.

Benamin Bambur
Benamin Bambur 12 Mar 2025

#Introduction

Hey there! 👋 I used to waste so much time constantly refreshing pages to check if a product was back in stock. It was frustrating, so I decided to solve my own problem by building Attenzione—a simple but powerful Symfony CLI tool that does all the work for me!

Now, instead of manually checking every few minutes, Attenzione watches web pages for specific HTML elements and sends me notifications when they appear. It’s like having a personal assistant dedicated to tracking product availability (or any other content you care about). Whether you're a developer, researcher, or just someone who’s tired of refreshing pages, this tool can make your life a lot easier!

#What is Attenzione?

Attenzione is a web scraping and monitoring tool built using Symfony’s Console component. It enables users to track the presence of specific HTML elements on web pages and receive notifications through desktop alerts and logs.

Key Features

  • Real-time Web Monitoring – Scans web pages for specified HTML elements.

  • Instant Notifications – Sends desktop alerts when elements are found.

  • Automated Tracking – Easily set up periodic monitoring using cron jobs.

  • Flexible Search Options – Allows monitoring by HTML tags, attributes, and CSS selectors.

  • Cross-Platform Compatibility – Works on Linux, macOS, and Windows. ( Not yet tested for macOs and Windows. )

  • Customizable Logging – Keeps records of all detected changes for easy tracking.

#How Attenzione Works

Attenzione operates through a simple command-line interface, allowing users to specify the URL, HTML tag, and attribute to track. When the specified element is detected on the web page, a notification is triggered.

Command Syntax

To check a webpage for a specific element, use the following command:

php bin/console app:run-notify <url> <tag> <tagName>

Where:

  • <url>: The web page to monitor.

  • <tag>: The HTML tag or CSS selector to search for.

  • <tagName>: The name attribute or class name to match.

#Example Use Cases

Monitoring Product Availability

E-commerce professionals can use Attenzione to track when a product is back in stock:

php bin/console app:run-notify https://www.example.com "button" "add-to-cart"

Tracking Website Changes

Developers and analysts can monitor changes on specific pages:

php bin/console app:run-notify https://store.example.org "div" "product-container"

#Setting Up Automated Monitoring

For continuous monitoring, users can set up cron jobs to run Attenzione at regular intervals.

Configuring a Cron Job

  1. Create a shell script:

#!/bin/bash

cd /path/to/attenzione

php bin/console app:run-notify "$1" "$2" "$3" >> var/log/cron.log 2>&1

  1. Make the script executable:

chmod +x bin/cron-run-notify.sh

  1. Schedule a cron job to run every 15 minutes:

*/15 * * * * /path/to/attenzione/bin/cron-run-notify.sh "https://www.example.com" "button" "add-to-cart"

Monitoring Multiple Pages

Users can set up a configuration file to track multiple URLs simultaneously:

# config/urls-to-check.txt https://www.example.com|button|add-to-cart https://store.example.org|div|product-container

Then create a script to process all URLs:

#!/bin/bash

cd /path/to/attenzione

cat config/urls-to-check.txt | while IFS="|" read -r URL TAG TAG_NAME; do

php bin/console app:run-notify "$URL" "$TAG" "$TAG_NAME" >> var/log/cron.log 2>&1

done

#Notifications & Logging

Desktop Notifications

Attenzione supports real-time desktop alerts using JoliNotif for cross-platform compatibility.

Log Files

  • Application logs: tag-notifications.log

  • Cron execution logs: cron.log

#Advanced Usage

Using CSS Selectors

For complex tracking, users can specify CSS selectors instead of simple HTML tags:

php bin/console app:run-notify https://example.com "button.buy-now[data-product-id]" "add-to-cart"

Element Search Strategy

Attenzione follows a multi-step strategy to find elements:

  1. Searches by tag name and checks the name attribute.

  2. If not found, searches by class name.

  3. Returns true if the tagName matches in either attribute.

#Troubleshooting

Desktop Notifications Not Working?

If notifications fail to appear:

  • Ensure DISPLAY, XAUTHORITY, and DBUS_SESSION_BUS_ADDRESS variables are set.

  • Install notify-send (Linux): sudo apt install libnotify-bin

  • Enable permissions (macOS).

  • Install BurntToast (Windows): Install-Module -Name BurntToast

Command Execution Issues?

Check logs for errors:

  • Application logs: tag-notifications.log

  • Cron logs: cron.log

#Conclusion

Attenzione is an essential tool for developers, businesses, and analysts who need to monitor web pages for dynamic changes. With its flexible command-line interface, automated tracking, and real-time notifications, it streamlines web monitoring effortlessly. Whether tracking product availability or detecting website modifications, Attenzione offers a simple and effective solution for all your web tracking needs.


#FAQs

1. Can Attenzione monitor multiple elements on the same page?
Yes, you can run multiple instances of the command or use a multi-URL script to track different elements on the same page.

2. Does Attenzione work on headless servers?
No, not yet the feature is in works. Stay tuned.

3. How frequently can I run Attenzione?
You can schedule it as often as needed using cron jobs, but frequent checks may put stress on target websites.

4. Does it support authentication for restricted pages?
Currently, it does not support login-based tracking, but future updates may include authentication support. Stay tuned.

5. Can I use Attenzione for SEO monitoring?
Yes! It can be used to track changes in meta tags, headings, and structured data on web pages.


With Attenzione, you can stay ahead of website updates and track changes efficiently with Symfony’s powerful CLI capabilities. 🚀

# Related Posts

No related posts found.