Created
December 18, 2018 00:23
-
-
Save xiwcx/baf8d9e57ff551a020114a76e5229a48 to your computer and use it in GitHub Desktop.
santa's little helper
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
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); |
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
{ | |
"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