$ npm i -g puppeteer
$ NODE_PATH=$(npm -g root) node uhk.js
> 20 days
Last active
October 18, 2018 15:58
-
-
Save adamyonk/6a881d61564a14a1000bcc147c8293f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const puppeteer = require("puppeteer"); | |
// Replace this with your own ID, not including any # symbol | |
const ID = 62180; | |
const run = async () => { | |
const browser = await puppeteer.launch({ headless: false }); | |
const page = await browser.newPage(); | |
await page.goto("https://ultimatehackingkeyboard.com/delivery-status"); | |
await page.waitFor("#app tr"); | |
let nodes = await page.$$eval("#app tr", nodes => | |
nodes.map(n => n.innerText) | |
); | |
let date = nodes.filter(t => t.match(` #?${ID} `))[0].match(/[^ ]*/)[0]; | |
if (date !== "shipped") { | |
date = Math.ceil((new Date(date) - new Date()) / 60 / 60 / 24 / 1000); | |
date += " days"; | |
} | |
console.log(date); | |
await browser.close(); | |
}; | |
try { | |
run(); | |
} catch (error) { | |
console.warn(error); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment