-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.js
More file actions
33 lines (26 loc) · 933 Bytes
/
parser.js
File metadata and controls
33 lines (26 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const accounting = require('accounting');
const nightmare = require('nightmare')();
const sendMail = require('./mailConfig');
// const params=process.argv.slice(2);
// let url = params[0];
// const minPrice = params[1];
async function checkPrice(url,minPrice,id) {
console.log("Checking " + url + " ............")
const priceString = await nightmare.
goto(url)
.wait("#priceblock_ourprice")
.evaluate(()=> document.getElementById("priceblock_ourprice").innerText)
.end();
const priceNumber = accounting.unformat(priceString)
console.log(priceNumber)
if(priceNumber<minPrice){
console.log("cheap")
await sendMail(id,`${priceNumber}`)
}else{
console.log("expensive")
}
}
const url = "https://www.amazon.in/Redgear-Pro-Wireless-Gamepad-Black/dp/B0756CLQWL"
const minPrice = 1800
const id = 'ishaanbholayo@gmail.com';
checkPrice(url,minPrice,id);