This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex3.js
152 lines (143 loc) · 4.21 KB
/
index3.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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import puppeteer from 'puppeteer'
import fs from 'fs'
const browser = await puppeteer.launch({
headless: false,
defaultViewport: null,
})
<<<<<<< HEAD
const page = await browser.newPage()
await page.goto('https://app.optimism.io/retropgf-discovery')
await page.waitForSelector('._primaryButton_7jap0_6')
while (true) {
try {
await page.$eval('._primaryButton_7jap0_6', (button) => button.click())
await page.waitForSelector('._primaryButton_7jap0_6', { timeout: 10000 })
} catch (error) {
break
=======
try {
const page = await browser.newPage()
await page.goto(
'https://app.optimism.io/retropgf-discovery/0xB30dD1198Feed1e22EC969f61EEd04cB75937adf'
)
await page.waitForTimeout(20000)
let temp = []
const scrap = async () => {
const name = await page.$eval('h1._header_bb8mr_1', (h1) => h1.textContent)
const about = await page.$eval(
'._content_i25cn_54 > section:nth-child(4) >p',
(p) => p.innerText
)
const question_1 = await page.$eval(
'._content_i25cn_54 > section:nth-child(6)>p:nth-child(3)',
(p) => p.innerText
)
const question_2 = await page.$eval(
'._content_i25cn_54 > section:nth-child(7)>p:nth-child(3)',
(p) => p.innerText
)
const team = await page.$eval(
'._content_i25cn_54 > section:nth-child(8)>p:nth-child(2)',
(p) => p.innerText
)
temp.push({ name, about, question_1, question_2, team })
console.log(temp)
>>>>>>> feat: retropgf3 ballot script
}
}
let linkArray = []
linkArray = await page.$$eval('a._container_1dvyk_1', (links) =>
links.map((a) => a.href)
)
// console.log(linkArray)
let temp = []
for (let each of linkArray) {
const eachpage = await browser.newPage()
await eachpage.goto(each)
await eachpage.waitForTimeout(5000)
const icon64 = await eachpage.$eval('._image_bb8mr_10', (img) => img.src)
const icon = Buffer.from(icon64.slice(22), 'base64')
let banner64, banner
try {
banner64 = await eachpage.$eval('._banner_i25cn_46 > img', (img) => img.src)
banner = Buffer.from(banner64.slice(22), 'base64')
} catch (err) {
banner = null
}
const name = await eachpage.$eval('h1._header_bb8mr_1', (h1) =>
h1 ? h1.textContent : 'Null'
)
const twitterElement = await eachpage.$(
'div._container_1gcg6_1 > a:nth-child(1)'
)
const twitter = twitterElement
? await twitterElement.evaluate((a) => a.href)
: 'Null'
const githubElement = await eachpage.$(
'div._container_1gcg6_1 > a:nth-child(2)'
)
const github = githubElement
? await githubElement.evaluate((a) => a.href)
: 'Null'
const websiteElement = await eachpage.$(
'div._container_1gcg6_1 > a:nth-child(3)'
)
const website = websiteElement
? await websiteElement.evaluate((a) => a.href)
: 'Null'
const aboutElement = await eachpage.$(
'._content_i25cn_54 > section:nth-child(4) > p'
)
const about = aboutElement
? await aboutElement.evaluate((p) => p.innerText)
: 'Null'
const question_1Element = await eachpage.$(
'._content_i25cn_54 > section:nth-child(6) > p:nth-child(3)'
)
const question_1 = question_1Element
? await question_1Element.evaluate((p) => p.innerText)
: 'Null'
const question_2Element = await eachpage.$(
'._content_i25cn_54 > section:nth-child(7) > p:nth-child(3)'
)
const question_2 = question_2Element
? await question_2Element.evaluate((p) => p.innerText)
: 'Null'
const teamElement = await eachpage.$(
'._content_i25cn_54 > section:nth-child(8) > p:nth-child(2)'
)
const team = teamElement
? await teamElement.evaluate((p) => p.innerText)
: 'Null'
await fs.mkdirSync(`each_project/${name}`, { recursive: true })
await fs.writeFileSync(
`each_project/${name}/info.json`,
JSON.stringify({
name,
twitter,
github,
website,
about,
question_1,
question_2,
team,
})
)
await fs.writeFileSync(`each_project/${name}/icon.jpg`, icon, 'binary')
if (banner) {
await fs.writeFileSync(`each_project/${name}/banner.jpg`, banner, 'binary')
}
await temp.push({
name,
twitter,
github,
website,
about,
question_1,
question_2,
team,
})
await console.log(temp)
await eachpage.close()
}
await browser.close()