This commit is contained in:
@@ -13,6 +13,9 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- cd /home/pi/warframe-market-bot
|
- cd /home/pi/warframe-market-bot
|
||||||
- git pull
|
- git pull
|
||||||
|
- name: install
|
||||||
|
commands:
|
||||||
|
- npm install
|
||||||
- name: restart
|
- name: restart
|
||||||
commands:
|
commands:
|
||||||
- PM2_HOME='/home/pi/.pm2' pm2 restart warframe-market-bot
|
- PM2_HOME='/home/pi/.pm2' pm2 restart warframe-market-bot
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
.vscode
|
.vscode
|
||||||
index.txt
|
index.html
|
||||||
|
|||||||
@@ -1,2 +1,5 @@
|
|||||||
|
# Warframe Market Bot
|
||||||
|
|
||||||
Список Прайм предметов: https://warframe.fandom.com/wiki/Prime
|
Список Прайм предметов: https://warframe.fandom.com/wiki/Prime
|
||||||
|
|
||||||
Маркет: https://warframe.market
|
Маркет: https://warframe.market
|
||||||
|
|||||||
6
index.js
6
index.js
@@ -12,7 +12,8 @@ async function initPuppeteer (page) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const browser = await puppeteer.launch({ executablePath: 'chromium-browser' })
|
// const browser = await puppeteer.launch({ executablePath: 'chromium-browser' })
|
||||||
|
const browser = await puppeteer.launch()
|
||||||
const page = await browser.newPage()
|
const page = await browser.newPage()
|
||||||
await initPuppeteer(page)
|
await initPuppeteer(page)
|
||||||
|
|
||||||
@@ -26,11 +27,10 @@ async function initPuppeteer (page) {
|
|||||||
|
|
||||||
const setPrice = await item.set.getPrice(page)
|
const setPrice = await item.set.getPrice(page)
|
||||||
if (partsPrice < setPrice) {
|
if (partsPrice < setPrice) {
|
||||||
output.addLine(`${item.name} prime: ${partsPrice}/${setPrice} выгода ${setPrice - partsPrice}`)
|
output.addItem(item.name, partsPrice, setPrice)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await browser.close()
|
await browser.close()
|
||||||
output.timestamp()
|
|
||||||
output.submit()
|
output.submit()
|
||||||
})()
|
})()
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ const primaries = [
|
|||||||
|
|
||||||
const items = []
|
const items = []
|
||||||
|
|
||||||
warframes.forEach((name) => {
|
// warframes.forEach((name) => {
|
||||||
items.push(new Warframe(name))
|
// items.push(new Warframe(name))
|
||||||
})
|
// })
|
||||||
|
|
||||||
primaries.forEach((name) => {
|
primaries.forEach((name) => {
|
||||||
items.push(new Primary(name))
|
items.push(new Primary(name))
|
||||||
|
|||||||
29
output.js
29
output.js
@@ -1,29 +0,0 @@
|
|||||||
const fs = require('fs')
|
|
||||||
|
|
||||||
class Output {
|
|
||||||
constructor () {
|
|
||||||
this.content = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
addLine (text) {
|
|
||||||
this.content += text + '\n'
|
|
||||||
}
|
|
||||||
|
|
||||||
timestamp () {
|
|
||||||
this.addLine('\n' + new Date())
|
|
||||||
}
|
|
||||||
|
|
||||||
submit () {
|
|
||||||
const filename = 'index.txt'
|
|
||||||
|
|
||||||
try {
|
|
||||||
fs.unlinkSync(filename)
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error)
|
|
||||||
console.log('File probably doesnt exist')
|
|
||||||
}
|
|
||||||
fs.writeFileSync(filename, this.content, 'utf-8')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = new Output()
|
|
||||||
9
output/OutputItem.js
Normal file
9
output/OutputItem.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
module.exports = class OutputItem {
|
||||||
|
constructor (name, parts, set) {
|
||||||
|
this.name = name + ' prime'
|
||||||
|
this.parts = parts
|
||||||
|
this.set = set
|
||||||
|
|
||||||
|
this.difference = set - parts
|
||||||
|
}
|
||||||
|
}
|
||||||
39
output/index.js
Normal file
39
output/index.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
const fs = require('fs')
|
||||||
|
const Handlebars = require('handlebars')
|
||||||
|
const OutputItem = require('./OutputItem')
|
||||||
|
|
||||||
|
class Output {
|
||||||
|
constructor () {
|
||||||
|
this.items = []
|
||||||
|
this.timestamp = null
|
||||||
|
}
|
||||||
|
|
||||||
|
addItem (...p) {
|
||||||
|
this.items.push(new OutputItem(...p))
|
||||||
|
}
|
||||||
|
|
||||||
|
async compileTemplate () {
|
||||||
|
const templateFile = await fs.readFileSync('./output/template.hbs', 'utf8')
|
||||||
|
const template = Handlebars.compile(templateFile)
|
||||||
|
return template(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
async writeToFile (content) {
|
||||||
|
const filename = 'index.html'
|
||||||
|
|
||||||
|
try {
|
||||||
|
await fs.unlinkSync(filename)
|
||||||
|
} catch {
|
||||||
|
console.log('File probably doesnt exist')
|
||||||
|
}
|
||||||
|
fs.writeFileSync(filename, content, 'utf-8')
|
||||||
|
}
|
||||||
|
|
||||||
|
async submit () {
|
||||||
|
this.timestamp = new Date()
|
||||||
|
const content = await this.compileTemplate()
|
||||||
|
await this.writeToFile(content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = new Output()
|
||||||
41
output/template.hbs
Normal file
41
output/template.hbs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Warframe Market Gaps</title>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul li b {
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timestamp {
|
||||||
|
font-size: small;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Warframe Market Gaps</h1>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{{#each items}}
|
||||||
|
<li>
|
||||||
|
<b>{{this.name}}</b>
|
||||||
|
Parts price: {{this.parts}}
|
||||||
|
Set price: {{this.set}}
|
||||||
|
Difference: {{this.difference}}
|
||||||
|
</li>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="timestamp">
|
||||||
|
Generated at {{timestamp}}
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
92
package-lock.json
generated
92
package-lock.json
generated
@@ -8,6 +8,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"handlebars": "^4.7.7",
|
||||||
"puppeteer": "^13.3.2"
|
"puppeteer": "^13.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -1354,6 +1355,26 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/handlebars": {
|
||||||
|
"version": "4.7.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz",
|
||||||
|
"integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==",
|
||||||
|
"dependencies": {
|
||||||
|
"minimist": "^1.2.5",
|
||||||
|
"neo-async": "^2.6.0",
|
||||||
|
"source-map": "^0.6.1",
|
||||||
|
"wordwrap": "^1.0.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"handlebars": "bin/handlebars"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.4.7"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"uglify-js": "^3.1.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/has": {
|
"node_modules/has": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
||||||
@@ -1840,9 +1861,7 @@
|
|||||||
"node_modules/minimist": {
|
"node_modules/minimist": {
|
||||||
"version": "1.2.5",
|
"version": "1.2.5",
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
||||||
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
|
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
|
||||||
"dev": true,
|
|
||||||
"peer": true
|
|
||||||
},
|
},
|
||||||
"node_modules/mkdirp-classic": {
|
"node_modules/mkdirp-classic": {
|
||||||
"version": "0.5.3",
|
"version": "0.5.3",
|
||||||
@@ -1861,6 +1880,11 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
|
"node_modules/neo-async": {
|
||||||
|
"version": "2.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
|
||||||
|
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw=="
|
||||||
|
},
|
||||||
"node_modules/node-fetch": {
|
"node_modules/node-fetch": {
|
||||||
"version": "2.6.7",
|
"version": "2.6.7",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
|
||||||
@@ -2292,6 +2316,14 @@
|
|||||||
"url": "https://github.com/chalk/slice-ansi?sponsor=1"
|
"url": "https://github.com/chalk/slice-ansi?sponsor=1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/source-map": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/sprintf-js": {
|
"node_modules/sprintf-js": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||||
@@ -2535,6 +2567,18 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/uglify-js": {
|
||||||
|
"version": "3.15.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.1.tgz",
|
||||||
|
"integrity": "sha512-FAGKF12fWdkpvNJZENacOH0e/83eG6JyVQyanIJaBXCN1J11TUQv1T1/z8S+Z0CG0ZPk1nPcreF/c7lrTd0TEQ==",
|
||||||
|
"optional": true,
|
||||||
|
"bin": {
|
||||||
|
"uglifyjs": "bin/uglifyjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/unbox-primitive": {
|
"node_modules/unbox-primitive": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz",
|
||||||
@@ -2639,6 +2683,11 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/wordwrap": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus="
|
||||||
|
},
|
||||||
"node_modules/wrappy": {
|
"node_modules/wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||||
@@ -3710,6 +3759,18 @@
|
|||||||
"type-fest": "^0.20.2"
|
"type-fest": "^0.20.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"handlebars": {
|
||||||
|
"version": "4.7.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz",
|
||||||
|
"integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==",
|
||||||
|
"requires": {
|
||||||
|
"minimist": "^1.2.5",
|
||||||
|
"neo-async": "^2.6.0",
|
||||||
|
"source-map": "^0.6.1",
|
||||||
|
"uglify-js": "^3.1.4",
|
||||||
|
"wordwrap": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"has": {
|
"has": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
||||||
@@ -4056,9 +4117,7 @@
|
|||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "1.2.5",
|
"version": "1.2.5",
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
||||||
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
|
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
|
||||||
"dev": true,
|
|
||||||
"peer": true
|
|
||||||
},
|
},
|
||||||
"mkdirp-classic": {
|
"mkdirp-classic": {
|
||||||
"version": "0.5.3",
|
"version": "0.5.3",
|
||||||
@@ -4077,6 +4136,11 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
|
"neo-async": {
|
||||||
|
"version": "2.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
|
||||||
|
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw=="
|
||||||
|
},
|
||||||
"node-fetch": {
|
"node-fetch": {
|
||||||
"version": "2.6.7",
|
"version": "2.6.7",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
|
||||||
@@ -4374,6 +4438,11 @@
|
|||||||
"is-fullwidth-code-point": "^3.0.0"
|
"is-fullwidth-code-point": "^3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"source-map": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
|
||||||
|
},
|
||||||
"sprintf-js": {
|
"sprintf-js": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||||
@@ -4570,6 +4639,12 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
|
"uglify-js": {
|
||||||
|
"version": "3.15.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.1.tgz",
|
||||||
|
"integrity": "sha512-FAGKF12fWdkpvNJZENacOH0e/83eG6JyVQyanIJaBXCN1J11TUQv1T1/z8S+Z0CG0ZPk1nPcreF/c7lrTd0TEQ==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"unbox-primitive": {
|
"unbox-primitive": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz",
|
||||||
@@ -4659,6 +4734,11 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
|
"wordwrap": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus="
|
||||||
|
},
|
||||||
"wrappy": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"author": "Anatoly Kopyl",
|
"author": "Anatoly Kopyl",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"handlebars": "^4.7.7",
|
||||||
"puppeteer": "^13.3.2"
|
"puppeteer": "^13.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user