-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
38 lines (36 loc) · 1 KB
/
index.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
37
38
const all = [];
function getTable(x){
const result = {};
const headingText = $$('.heading')[x].innerText;
result[headingText] = {};
const tableEle = $$('.type-table')[x];
const trArr = tableEle.querySelectorAll('.single-detail');
for(let i=0; i<trArr.length; i++){
const thArr = trArr[i].getElementsByTagName('td');
const id = thArr[0].innerText;
const nameSy = thArr[1].getElementsByTagName('a')[0].getAttribute('href');
const name = nameSy.split('/')[nameSy.split('/').length-1];
const desc = thArr[2].innerText;
all.push({
name,
id
});
result[headingText][name] = {
id,
name,
desc,
}
}
return result
}
const result = {
nodePack: {},
};
function getAll(){
const allHeading = $$('.heading');
for(let i=0; i<allHeading.length; i++){
Object.assign(result.nodePack, getTable(i))
}
result.other = all;
return JSON.stringify(result);
}