<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kenn Williams</title>
    <description>The latest articles on DEV Community by Kenn Williams (@kenn_williams_4396ca9a358).</description>
    <link>https://dev.to/kenn_williams_4396ca9a358</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4255587%2Fa7aef28e-36b1-4234-a5c7-1fd719ac34cd.jpg</url>
      <title>DEV Community: Kenn Williams</title>
      <link>https://dev.to/kenn_williams_4396ca9a358</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kenn_williams_4396ca9a358"/>
    <language>en</language>
    <item>
      <title>I Built a Price Tracking Tool Using Python and Web Scraping</title>
      <dc:creator>Kenn Williams</dc:creator>
      <pubDate>Fri, 20 Nov 2026 12:18:24 +0000</pubDate>
      <link>https://dev.to/kenn_williams_4396ca9a358/i-built-a-price-tracking-tool-using-python-and-web-scraping-3424</link>
      <guid>https://dev.to/kenn_williams_4396ca9a358/i-built-a-price-tracking-tool-using-python-and-web-scraping-3424</guid>
      <description>&lt;p&gt;I often find myself checking the same products across different online stores to see whether their prices have changed. Sometimes a product becomes cheaper after a few days, while other times the price stays exactly the same.&lt;/p&gt;

&lt;p&gt;Doing this manually can become frustrating, especially when comparing products across multiple websites.&lt;/p&gt;

&lt;p&gt;That made me curious: Could I build a simple tool that automatically checks product prices and keeps track of changes?&lt;/p&gt;

&lt;p&gt;I decided to experiment with Python and web scraping. The goal was simple: create a small price tracking tool that collects product information, stores prices, and helps identify when a product becomes cheaper.&lt;/p&gt;

&lt;p&gt;In this article, I'll walk through how I approached the project and share the basic code behind it.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Understanding the Idea Behind Price Tracking
&lt;/h2&gt;

&lt;p&gt;Before writing any code, I wanted to understand what the tool actually needed to do.&lt;/p&gt;

&lt;p&gt;A basic price tracking system should be able to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Collect product names and prices from supported websites.&lt;/li&gt;
&lt;li&gt;Save the collected information.&lt;/li&gt;
&lt;li&gt;Check prices again after some time.&lt;/li&gt;
&lt;li&gt;Compare current prices with previous records.&lt;/li&gt;
&lt;li&gt;Identify products whose prices have decreased.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think about someone browsing the top online shopping sites to compare the price of a pair of headphones. Instead of opening several tabs every day, a tracking tool could collect the available prices and organize them in one place.&lt;/p&gt;

&lt;p&gt;This is also connected to consumer behavior examples. People often compare prices, wait for discounts, and revisit products before making a purchase. Tracking price changes can make these decisions easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Setting Up the Python Environment
&lt;/h2&gt;

&lt;p&gt;For this project, I used Python because it offers simple libraries for collecting and processing web data.&lt;/p&gt;

&lt;p&gt;We'll need three main libraries:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;requests – to send HTTP requests.&lt;/li&gt;
&lt;li&gt;BeautifulSoup – to extract information from HTML.&lt;/li&gt;
&lt;li&gt;csv – to store product prices.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Install the required libraries:&lt;/p&gt;

&lt;p&gt;pip install requests beautifulsoup4&lt;/p&gt;

&lt;p&gt;The CSV module is already included in Python, so there's no need to install it separately.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Collecting Product Information
&lt;/h2&gt;

&lt;p&gt;The first step is retrieving product information from a webpage.&lt;/p&gt;

&lt;p&gt;For this example, I'm using a simple HTML structure to demonstrate how scraping works. In a real project, you should use a website that permits automated access or an official product API.&lt;/p&gt;

&lt;p&gt;Here is a basic example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;bs4&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;BeautifulSoup&lt;/span&gt;

&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://example.com/product"&lt;/span&gt;

&lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"User-Agent"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"PriceTracker/1.0"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"html.parser"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;product_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;select_one&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;".product-title"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;product_price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;select_one&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;".product-price"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;product_name&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;product_price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Product:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product_name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Price:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;product_price&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Product information was not found."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CSS selectors .product-title and .product-price are examples. They must be replaced with the actual selectors used by the website you're working with.&lt;/p&gt;

&lt;p&gt;This is an important part of web scraping: every website has its own HTML structure, so the extraction logic needs to match the page.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Saving Prices in a CSV File
&lt;/h2&gt;

&lt;p&gt;Collecting prices is useful, but saving them allows us to compare changes over time.&lt;/p&gt;

&lt;p&gt;I used Python's built-in CSV module to create a simple record of product prices.&lt;/p&gt;

&lt;p&gt;import csv&lt;br&gt;
from datetime import datetime&lt;/p&gt;

&lt;p&gt;def save_price(product, price, filename="prices.csv"):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;with open(
    filename,
    "a",
    newline="",
    encoding="utf-8"
) as file:

    writer = csv.writer(file)

    writer.writerow([
        datetime.now().isoformat(timespec="seconds"),
        product,
        price
    ])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;save_price("Wireless Headphones", 89.99)&lt;/p&gt;

&lt;p&gt;Every time the function runs, it adds a new record containing the date, product name, and price.&lt;/p&gt;

&lt;p&gt;After several checks, the CSV file might look like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Product&lt;/th&gt;
&lt;th&gt;Price&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Nov 18&lt;/td&gt;
&lt;td&gt;Wireless Headphones&lt;/td&gt;
&lt;td&gt;€99.99&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nov 19&lt;/td&gt;
&lt;td&gt;Wireless Headphones&lt;/td&gt;
&lt;td&gt;€94.99&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nov 20&lt;/td&gt;
&lt;td&gt;Wireless Headphones&lt;/td&gt;
&lt;td&gt;€89.99&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Now we have something useful: a basic price history.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Detecting Price Changes
&lt;/h2&gt;

&lt;p&gt;The next step is comparing the latest price with the previous recorded price.&lt;/p&gt;

&lt;p&gt;def check_price_drop(old_price, new_price):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if new_price &amp;lt; old_price:
    difference = old_price - new_price

    print(
        f"Price dropped by €{difference:.2f}"
    )

elif new_price &amp;gt; old_price:
    print("The price has increased.")

else:
    print("The price has not changed.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;check_price_drop(99.99, 89.99)&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;Price dropped by €10.00&lt;/p&gt;

&lt;p&gt;This simple comparison is the foundation of a price alert system.&lt;/p&gt;

&lt;p&gt;A more advanced version could send an email or notification whenever a product reaches a price that the user has selected.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Connecting Price Tracking With Online Shopping
&lt;/h2&gt;

&lt;p&gt;One interesting thing about this project is how it connects programming with everyday shopping decisions.&lt;/p&gt;

&lt;p&gt;For example, someone might add a product to their online shopping cart but decide not to purchase it immediately. They may want to compare prices, wait for a promotion, or check whether another retailer offers a better deal.&lt;/p&gt;

&lt;p&gt;A price tracking tool can help organize this information and make comparisons easier.&lt;/p&gt;

&lt;p&gt;Top saving platforms such as Ozbargain and EMUCoupon also fit into this broader online shopping experience by helping shoppers discover available discounts and promotional offers.&lt;/p&gt;

&lt;p&gt;Price monitoring and coupon discovery serve slightly different purposes, but both can help shoppers make more informed purchasing decisions.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. What I Would Improve Next
&lt;/h2&gt;

&lt;p&gt;The first version of my tool is intentionally simple. However, there are several ways I would improve it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Database integration:&lt;/strong&gt; Replace CSV storage with SQLite or PostgreSQL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automated scheduling:&lt;/strong&gt; Use a scheduler to check prices periodically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Price history charts:&lt;/strong&gt; Visualize how product prices change over time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Email notifications:&lt;/strong&gt; Notify users when prices fall below their target.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multiple product support:&lt;/strong&gt; Track several products from different supported retailers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dashboard:&lt;/strong&gt; Build a simple interface using Flask or Streamlit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I would also add better error handling, respect website terms of service and robots.txt guidance, and use official APIs wherever possible.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Takeaways
&lt;/h3&gt;

&lt;p&gt;Building a price tracking tool with Python showed me how a relatively small programming project can solve an everyday problem.&lt;/p&gt;

&lt;p&gt;The combination of web scraping, data storage, and price comparison provides a useful starting point for anyone interested in automation and e-commerce development.&lt;/p&gt;

&lt;p&gt;You don't need to build a complicated platform immediately. Start with one product, collect its price, save the data, and gradually add more features.&lt;br&gt;
Sometimes the best coding projects begin with a simple question: Can I automate something I keep doing manually?&lt;/p&gt;

</description>
      <category>python</category>
      <category>webscraping</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
