-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmember.js
More file actions
68 lines (65 loc) · 1.88 KB
/
member.js
File metadata and controls
68 lines (65 loc) · 1.88 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const axios = require("axios");
const {
cleanString,
getTableTag,
getMainContent,
getDivTag,
getTrTag,
getTdTag,
removeTag,
replaceBr,
replaceClearDiv,
replaceAlamatHadiahDiv,
} = require("./helper");
axios.get('https://jkt48.com/member/list?lang=id')
.then(({ data }) => {
const content = replaceAlamatHadiahDiv(replaceClearDiv(cleanString(getMainContent(data)[0])))
const divs = getDivTag(content).slice(0, getDivTag(content).length - 3);
let imgTemp = ''
let key = ''
let result = {}
divs.forEach((d, i) => {
const getImg = d.match(/(?<=src=").*?(?=[\?"])/g)
const getUrl = d.match(/(?<=href=").*?(?=[\?"])/g)
const getContent = removeTag(replaceBr(d))
const isTeam = getContent.split(' ')[0] == 'Team'
const isEnd = getContent.split(' ')[0] == 'Trainee'
const isImg = getImg !== null
if (isTeam) {
key = getContent
} else {
if (isImg) {
imgTemp = getImg[0]
} else {
result[getContent] = { ...result[getContent] }
result[getContent]['team'] = key
result[getContent]["url"] = `https://jkt48.com${getUrl}`
result[getContent]['image'] = `https://jkt48.com${imgTemp}`
}
}
})
console.log('Core Team:', result)
})
.catch(err => {
console.log(err)
})
axios.get("https://jkt48.com/jkt48-academy/member-academy")
.then(({data}) => {
const table = getTableTag(data)
const cleanTable = cleanString(table[0])
const trTag = getTrTag(cleanTable).slice(0)
const result = {}
trTag.forEach(tr => {
const tdTag = getTdTag(tr).slice(0)
tdTag.forEach(td => {
const getImg = td.match(/(?<=src=").*?(?=[\?"])/g)[0]
const name = removeTag(replaceBr(td)).slice(0, removeTag(replaceBr(td)).length - 2)
result[name] = {}
result[name]['image'] = `https://jkt48.com${getImg}`
})
})
console.log('Academy:', result)
})
.catch(err => {
console.log(err)
})