Part class
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
const Part = require('./Part')
|
||||
|
||||
module.exports = class Item {
|
||||
constructor (name) {
|
||||
this.name = name
|
||||
this.url = `${this.name}_prime_set`
|
||||
this.set = new Part(name, 'set')
|
||||
|
||||
this.parts = []
|
||||
this.addPart('blueprint')
|
||||
}
|
||||
|
||||
addPart (part) {
|
||||
this.parts.push({ part, url: `${this.name}_prime_${part}` })
|
||||
this.parts.push(new Part(this.name, part))
|
||||
}
|
||||
}
|
||||
|
||||
15
items/Part.js
Normal file
15
items/Part.js
Normal file
@@ -0,0 +1,15 @@
|
||||
module.exports = class Part {
|
||||
constructor (set, part) {
|
||||
this.part = part
|
||||
this.url = `${set}_prime_${part}`
|
||||
}
|
||||
|
||||
async getPrice (page) {
|
||||
const marketUrl = 'https://warframe.market/items/'
|
||||
|
||||
await page.goto(marketUrl + this.url)
|
||||
const element = await page.waitForSelector('b.price')
|
||||
const value = await element.evaluate(el => el.textContent)
|
||||
return Number(value)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user