Automated Price Monitoring with Python and CSV
A Python script uses cron, CSV files, and Telegram alerts to monitor product price changes across e-commerce sites. The method relies on parsing structured data from web pages rather than traditional HTML scraping.

A Python script allows users to monitor product page prices by extracting structured data from websites using JSON-LD, which is embedded by most e-commerce platforms. This approach avoids the instability of parsing raw HTML with regex, as described in the Dev.to article. The script relies on a CSV file to store price history and uses cron to schedule periodic checks, eliminating the need for a database or paid plan. The script also sends price change alerts via Telegram, ensuring users are notified of any fluctuations in product prices. [1]
The script uses the JSON-LD structured data found in a <script type="application/ld+json"> block on most shop platforms, such as Shopify and WooCommerce, to extract the offers.price field. If this data is not available, it falls back to regex-based extraction. The script also includes a User-Agent header to avoid being blocked by CDNs, as noted in the Dev.to article. It handles price formatting differences between regions by normalizing decimal points before converting to a float, which is essential for accurate price comparisons. [1]
The script writes price changes to a CSV file, which can be used to track historical price trends. It sends alerts only when a price change is detected, avoiding false positives caused by non-price-related HTML changes. The Dev.to article highlights that the script uses a 30-minute polling interval to avoid being flagged as a bot by shop CDNs, ensuring reliable and consistent monitoring of product prices over time. [1]
The script described in the source is designed to monitor product pages for price changes by extracting prices from structured data embedded in web pages. It targets URLs provided in a text file, with the example given being 'https://example.com/product/widget'. The project scope includes fetching HTML content, parsing price information using JSON-LD structured data, and sending alerts via Telegram when a price change is detected. The script is intended for users who want to track price fluctuations without relying on paid services or complex frameworks. The history of the script's development is not explicitly detailed, but it is presented as a lightweight, self-contained solution with no database or external dependencies, relying instead on a CSV file to store price history data. This data can be opened in any spreadsheet application for visualization and analysis. The script is executed as a cron job, with the example command suggesting it runs every 30 minutes. [1]
Advertisement
The script includes specific handling for different decimal formats, such as European (1.299,00) and US (1,299.00) conventions, to ensure correct price parsing. It uses a User-Agent string that is explicitly defined in the code to avoid being blocked by CDNs, which is a documented limit of the approach. The script also accounts for potential issues with JavaScript-rendered pages by suggesting the use of a headless browser like Playwright to fetch content after the page has fully loaded. This is a documented workaround for sites that do not expose price data in static HTML. Additionally, the script includes a fallback to regular expressions for extracting prices from HTML if JSON-LD data is not available, though this is noted as less reliable. The project is designed to be run on a regular basis, with a recommended poll interval of 30 minutes to avoid being flagged as a bot by shop CDNs. [1]
The script operates by monitoring product pages on various e-commerce platforms, including Shopify, WooCommerce, Magento, and BigCommerce, which all commonly use schema.org structured data in a <script type="application/ld+json"> block. This method allows for reliable price extraction by parsing the JSON-LD data, which contains the offers.price field. The project is designed to be lightweight, utilizing a CSV file to store historical price data without the need for a database. The script is executed via cron, and alerts are sent through Telegram when price changes are detected. The code is structured to handle both JSON-LD and regex-based price extraction, ensuring robustness against site redesigns or missing structured data. The CSV file serves a dual purpose as both a history log and a data source for visualizing price trends in spreadsheet software. The script also includes a user-agent string to avoid being blocked by CDNs, and it handles decimal formatting differences between European and US shops by normalizing the price values before conversion to float. The project is intended for users who want an affordable and straightforward solution to monitor price changes on product pages without the overhead of complex frameworks or databases. [1]
The script's implementation includes specific handling for different types of price formatting, such as European and US conventions, and it uses a custom user-agent string to prevent being blocked by CDNs. The project was developed with the intention of providing a low-cost solution for monitoring product prices, as the author runs a small $1 software store where the goal is to collect honest user reviews before introducing real pricing. The script includes a Telegram alert system that sends notifications when price changes are detected, and it writes the price history to a CSV file that can be used for charting in spreadsheet software. The script also includes a fallback to regular expressions for price extraction when JSON-LD is not available, ensuring that it can still function on sites that do not use structured data. The project is designed to be run on a regular basis using cron, with a recommended poll interval of 30 minutes to avoid being flagged as a bot by shop CDNs. The script also includes a sleep function to avoid hammering the server by sending too many requests in a short period of time. [1]
Sources
Prepared with AI assistance from the cited sources.
The Cali Reporter newsletter
The stories worth your time.
California, the country, and what comes next. Join our free newsletter for reporting that keeps you informed.
More in Technology
- Modern Web Guidance 1.0 and Browser Compatibility
Modern Web Guidance 1.0, announced by Chrome for Developers on November 10, introduces browser compatibility data to assist coding agents in building web features. The initiative emphasizes the importance of fallback…
- Apache mod_http2 Vulnerability Detection with Nmap
A new Nmap scripting module has been developed to detect the Apache mod_http2 vulnerability (CVE-2026-119618), addressing the challenges of identifying affected systems accurately.
- Securing Remote Vendor Access in Industrial Networks
Best practices for managing remote vendor access in operational technology (OT) networks emphasize controlled access points, multifactor authentication, and time-bound sessions to reduce cybersecurity risks.
