Hi
Well, Today we will discuss How to built Amazon Price Tracker by scraping the price details and scheduling with WayScript
Lemme tell you the real reason to build this ;)
I'm a foodie I love Nutella 🤤 but due to this pandemic, I couldn't find Nutella near me in any local stores. So I thought to order it in Amazon but the prices are damn high and prices are fluctuating too... then I started to build a tracker which notifies me whenever the price goes down the tracking price.
Let's get started..
We gonna create a python script which uses request and beautifulSoup module to scrape the data and scheduling the script to run every hour either with Serverless AWS Lambda or WayScript but AWS Lambda is not my cup of tea. So I built using WayScript.
We will discuss this process in 2 phases.
Phase I : Scraping the product details
Phase II : Scheduling the script to run every hour
Phase I:
Step 1: Create an excel sheet with urls and Tracking Price
Step 2: import necessary packages/module
import requests
import bs4
import pandas as pd
Request - The requests module allows you to send HTTP requests using Python
bs4 - Beautiful Soup is a library that makes it easy to scrape information from web
pandas - pandas is a fast and powerful used for data analysis.
we are faking ourselves as a Firefox user to avoid restrictions.
HEADERS = ({'User-Agent':
'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
'Accept-Language': 'en-US, en;q=0.5'})
Step 3: Building Python Script
Here is the tracker function which takes parameters URL and TrackingPrice and adds the details of the product when it is less or than equal to TrackingPrice
def tracker(url,TrackingPrice):
res = requests.get(url,headers=HEADERS)
soup = bs4.BeautifulSoup(res.content, features='lxml')
# to prevent script from crashing when there isn't a price for the product
try:
title = soup.find(id="productTitle").get_text().strip()
amount = float(soup.find(id='priceblock_ourprice').get_text().replace("₹","").replace("$","").strip())
if amount<=TrackingPrice:
offer.append("You got a offer on the {0} for {1}. Check out the product {2}".format(title,amount,url))
except:
offer.append("Couldn't get details about product")
Source Code:
import requests
import bs4
import pandas as pd
HEADERS = ({'User-Agent':
'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
'Accept-Language': 'en-US, en;q=0.5'})
offer=[]
def tracker(url,TrackingPrice):
res = requests.get(url,headers=HEADERS)
soup = bs4.BeautifulSoup(res.content, features='lxml')
# to prevent script from crashing when there isn't a price for the product
try:
title = soup.find(id="productTitle").get_text().strip()
amount = float(soup.find(id='priceblock_ourprice').get_text().replace("₹","").replace("$","").strip())
if amount<=TrackingPrice:
offer.append("You got a offer on the {0} for {1}. Check out the product {2}".format(title,amount,url))
except:
offer.append("Couldn't get details about product")
df=pd.read_csv("https://docs.google.com/spreadsheets/d/1AzJ93zR6--4vwl81W3v0FHyZ_bFMkFYRxOSjodJu_Qw/export?format=csv")
for i in range(0,len(df["URL"])):
tracker(df["URL"][i],df["TrackingPrice"][i])
outputs["message"]=offer
Output:
we're done with our python script
Now let's move to Phase II
Phase II:
I already told you can schedule this script either by using AWS Lambda or any other cloud computing services as I'm not familar with AWS. I'm going with WayScript
And this WayScript provide wide range of packages to interact with services
Ex:
- Gmail
- Text Message
- Charts
- Figma
- Slack
- Trello
Step 1: Open WayScript
Packages used for this scheduling:
- Time Trigger
- Python
- Loop
- Text Message
Step 2: Explaining everything in blog is not possible and people get cumbersome. So I made video of "How to configure the Python Script in WayScript.
Kindly Follow the video
Click here to check my configuration in WayScript
On one lucky day..
The price got reduced and this script notified me by sending a text message and I ordered it 😁
If you like my content, please consider supporting me
Hope it's useful
A ❤️ would be Awesome 😊
Top comments (11)
I tried to build the price checker for some GPUs but after a few request while testing one link mind you manually I started getting Amazon error page telling me to use their API. How did you make it so that you were not blocked?
I never got an error page like that..
Oh, thank you anyway, I learned a lot about building this type of apps.
Glad you liked it!!
The article provides a step-by-step guide on setting up and implementing the price tracker, including setting up an Amazon Web Services account, building a Python script, and integrating it with WayScript. The writer also explains the benefits of using WayScript, such as its ability to automate the price checking process and send email notifications when prices drop.
I appreciated how the writer provided plenty of code examples and screenshots to help readers follow along with the process. The article also includes a useful section on troubleshooting common errors and problems that may arise during implementation.
Overall, I found this article to be a valuable resource for anyone who wants to build their own custom Amazon price tracker using Python and WayScript. The tutorial is well-written and easy to understand, making it a great starting point for developers who are new to building automation tools.
I Read a similar article related to price tracking please check out and let me know what you think👉 webdataguru.com/competitor-price-t...
Lol, that's the best reason I've ever read to build a tool! Great job!
Thanks 😂
Hello, I wonder if you can make a program that adds more than one product, tracks it and notifies us by e-mail? we would be grateful
Some comments may only be visible to logged-in visitors. Sign in to view all comments.