-
Notifications
You must be signed in to change notification settings - Fork 0
/
gildables.js
36 lines (29 loc) · 1.26 KB
/
gildables.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// visit the following link and run the script https://ringofbrodgar.com/wiki/Tables/Gildable_Equipment
function scrape_gildables(document){
let tables = document.getElementsByTagName("tbody")
let items = []
for (let i = 0; i < tables.length; i++) {
let tbody = tables[i].children
for (let j = 0; j < tbody.length; j++) {
let el = tbody[j].children
let item = {}
item.icon = el[0].childNodes[0].childNodes[0].src
item.name = el[0].childNodes[2].innerHTML
item.link = el[0].childNodes[2].href
let affinity = []
for (let i = 0; i < el[1].childNodes.length; i+=2) {
affinity.push(el[1].childNodes[i].innerHTML)
}
item.affinity = affinity
item.chance_min = (el[2].innerHTML).split("-")[0]
item.chance_max = (el[2].innerHTML).split("-")[1]
item.slots = el[3].innerText.split("\n")[0].split(";")
for (let i = 0; i < item.slots.length; i++) {
item.slots[i] = item.slots[i].trim()
}
items.push(item)
}
}
return items
}
module.exports = scrape_gildables;