-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueryBoost.js
78 lines (73 loc) · 3.47 KB
/
queryBoost.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
const puppeteer = require('puppeteer');
async function boostPool() {
const browser = await puppeteer.launch({
args: [
'--no-sandbox',
'--headless',
'--disable-gpu',
'--window-size=1920x1080',],
headless: true, // no window
executablePath: 'C:\\chromium\\chrome.exe' // chromium executable program directory
});
const page = await browser.newPage();
await page.goto('https://testnetv2.doubler.pro/#/pool');
const element = await page.$x(`//*[@id="root"]/div/div/div/div[2]/div/div[2]/div[2]/div/div/div`)
await element[0].click()
await sleep(4000)
await page.waitForSelector('#root > div > div > div > div.sc-eqUAAy.gAfwzq.page-container > div > div.third_part > div.ant-table-wrapper > div > div > div > div > div.ant-table-body > table')
await sleep(4000)
const result = []
for (let i = 2;i < 1000;i++) {
const poolIds = await page.$x(`//*[@id="root"]/div/div/div/div[2]/div/div[2]/div[3]/div/div/div/div/div[2]/table/tbody/tr[${i}]/td[1]/div`)
let str = ''
if (poolIds.length > 0) {
const textValue = await page.evaluate(el => el.textContent, poolIds[0]);
str+='id:'+textValue;
} else break;
const symbols = await page.$x(`//*[@id="root"]/div/div/div/div[2]/div/div[2]/div[3]/div/div/div/div/div[2]/table/tbody/tr[${i}]/td[2]/div/span`)
if (symbols.length > 0) {
const textValue = await page.evaluate(el => el.textContent, symbols[0]);
str+=' '+textValue;
}
// const tvl = await page.$x(`//*[@id="root"]/div/div/div/div[2]/div/div[2]/div[3]/div/div/div/div/div[2]/table/tbody/tr[${i}]/td[4]/div/div/span/span`)
const floorPrice = await page.$x(`//*[@id="root"]/div/div/div/div[2]/div/div[2]/div[3]/div/div/div/div/div[2]/table/tbody/tr[${i}]/td[5]/div/div/div[1]/span`)
if (floorPrice.length > 0) {
// fetch content
const textValue = await page.evaluate(el => el.textContent, floorPrice[0]);
str+=' floorP:'+textValue;
}
const profitPrice = await page.$x(`//*[@id="root"]/div/div/div/div[2]/div/div[2]/div[3]/div/div/div/div/div[2]/table/tbody/tr[${i}]/td[5]/div/div/div[2]/span`)
if (profitPrice.length > 0) {
// fetch content
const textValue = await page.evaluate(el => el.textContent, profitPrice[0]);
str+=' profitP:'+textValue;
}
const layer = await page.$x(`//*[@id="root"]/div/div/div/div[2]/div/div[2]/div[3]/div/div/div/div/div[2]/table/tbody/tr[${i}]/td[6]/div[2]`)
if (layer.length > 0) {
// fetch content
const textValue = await page.evaluate(el => el.textContent, layer[0]);
str+=' layer:'+textValue;
}
// const shareRadio = await page.$x(`//*[@id="root"]/div/div/div/div[2]/div/div[2]/div[3]/div/div/div/div/div[2]/table/tbody/tr[${i}]/td[7]`)
// const lastLayerReward = await page.$x(`//*[@id="root"]/div/div/div/div[2]/div/div[2]/div[3]/div/div/div/div/div[2]/table/tbody/tr[${i}]/td[8]`)
const status = await page.$x(`//*[@id="root"]/div/div/div/div[2]/div/div[2]/div[3]/div/div/div/div/div[2]/table/tbody/tr[${i}]/td[9]/div/span[2]`)
if (status.length > 0) {
// fetch content
const textValue = await page.evaluate(el => el.textContent, status[0]);
str+=' status:'+textValue;
}
await sleep(1000)
result.push(str)
}
// await sleep(1000)
await browser.close();
// await sleep(1000)
return result ;
}
async function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve,ms));
}
// boostPool()
module.exports = {
boostPool
}