Skip to content

Instantly share code, notes, and snippets.

@xiwcx
Created December 18, 2018 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiwcx/baf8d9e57ff551a020114a76e5229a48 to your computer and use it in GitHub Desktop.
Save xiwcx/baf8d9e57ff551a020114a76e5229a48 to your computer and use it in GitHub Desktop.
santa's little helper
const http = require('http');
const cheerio = require('cheerio');
const opn = require('opn');
let count = 0;
const options = {
host: 'www.silkparlor.com',
port: 80,
path: '/shop/',
headers: {
'User-Agent': 'request'
}
};
async function intervalFunc() {
await http.get(options, function (res) {
let body;
res.on('data', (chunk) => {
body += chunk;
}).on('end', () => {
count = count + 1
const $ = cheerio.load(body)
items = $('.post-type-store-item').length
if (items !== 9) {
opn(`http://${options.host}${options.path}#content-wrapper`);
} else{
if (!(count % 6)) console.log(`===== Minute ${count / 6} =====`)
console.log('nope')
}
});
}).on('error', function (e) {
console.log("Got error: " + e.message);
});
}
setInterval(intervalFunc, 5 * 1000);
{
"name": "santas-little-helper",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"cheerio": "^1.0.0-rc.2",
"opn": "^5.4.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment