JavaScript quick-start project for amazon.in
price tracking.
π Tools required to develop the price-tracker
- NodeJs
- Puppeteer
- SendGrid/Mail
- CronJob
π€ Requirements
In order to utilise this project you need to have the following installed locally:
- nodejs
- npm
- puppeteer
- cheerio
- sendgrid/mail
- cron
To install the dependencies locally run:
npm install dependencies
In order for the price tracking to pass, you will need to configure the script with the following parameters:
- Setup/Replace the to and from email addresses in the
sendEmail()
function
function sendEmail(subject, body) {
const email = {
to: "*****@yourmail.com",
from: "*****@yourmail.com",
subject: subject,
text: body,
html: body,
};
return sgMail.send(email);
}
- Setup/Replace the sendgrid api key from the sendgrid account, and place it locally in a
.env
file.
SENDGRID_API_KEY= *****
- Setup/Replace the cron job with desired time interval in the
startTracking()
function
async function startTracking() {
const page = await configureBrowser();
let job = new CronJob(
"* */30 * * * *",
function () {
//runs every 30 minutes in this config
checkPrice(page);
},
null,
true,
null,
null,
true
);
job.start();
}
π·ββοΈ Usage
The project is basically a Nodejs script that can be run from the command line. In order to run this locally you need to clone the project and set up requirements and run the command:
node track <amazon.in-url-to-track> <price-threshold>
amazon.in-url-to-track
is the url of the product you want to trackprice-threshold
is the price limit you want to track for the product
πΉ Demo Video
π€ Template Repository
Β