A while ago I stayed up to try to get my hands on the latest technological device, but I was not able to get my hands on one because it was sold to mostly robots. How annoying. I am not going to teach you how to buy things with robots, but I will teach you how to check if an item is available. Please remember that this is just for information. It is actually against most terms and conditions to scrape data from retailer websites.

Let’s Start

The process is straight forward:

  1. Check if website has available item.
    1. Send yourself a notification email.

To achieve this, we will be working with three python libraries.

  • requests
  • beautifulsoup
  • smtplib
  • ssl
  • datetime

These libraries will allow us to perform all the previous steps we listed and some. First, we need to figure out what we want to scrape. To keep things informational, I decided to scrape a fictional website for a fictional item called X5. My strategy is simple, X5 is sold out most of the time, so if the website does not have the words “Unavailable” in their “add to cart” button, then it means X5 is available and ready to purchase. I went on to the dictional website, to the page for X5, and I located the “add to cart” button on the html. Luckily, the class name on the button was conveniently named “add-to-cart-button”. I am not even making up that part, so I did the following.

#python #shopping #automation #data-mining

Checking Retailer Stock Using Python
1.75 GEEK