-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.js
62 lines (55 loc) · 2.31 KB
/
parser.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
const nightmare = require("nightmare")({ waitTimeout: 120000 });
const binance_url = "https://p2p.binance.com/en/trade/buy/USDT"
const bitkub_url = "https://www.bitkub.com/market/USDT";
/*
select Fiat Button: #C2Cfiatfilter_searhbox_fiat
Buy button: .css-1bgspcv>.css-xbxtuo
Sell button: .css-1bgspcv>.css-yxrkwa
Fiat THB: #THB
(FindAll)
(Buy)
List of Advertisers: .css-16g55fu>.css-cjwhpx>.css-vurnku>.css-79tjl5
List of Advertisers' name: #C2Cofferlistsell_link_merchant
List of Advertisers' price: .css-4ptx7h>.css-1kj0ifu>.css-1m1f8hn
(Sell)
List of Advertisers: .css-vurnku>.css-79tjl5
List of Advertisers' name: #C2Cofferlistbuy_link_merchantdetail
List of Advertisers' price: .css-1kj0ifu>.css-1m1f8hn
*/
module.exports = {
getDataBinance: async () => {
try {
const buyResult = await nightmare
.goto(binance_url)
.wait(".css-vurnku>.css-79tjl5") // Delay
.click("#THB") // Select THB
.wait("#C2Cofferlistsell_link_merchant")
.evaluate(() => {
let price_arr = []
let prices = document.querySelectorAll(".css-4ptx7h>.css-1kj0ifu>.css-1m1f8hn");
prices.forEach((elem) => {
price_arr.push(elem.innerText);
});
return price_arr[1];
});
const sellResult = await nightmare
.click(".css-1bgspcv>.css-yxrkwa") // ---- sell button ----
.wait("#C2Cofferlistbuy_link_merchantdetail")
.wait(1000)
.evaluate(() => {
let price_arr = []
let prices = document.querySelectorAll(".css-1kj0ifu>.css-1m1f8hn");
prices.forEach((elem) => {
price_arr.push(elem.innerText);
});
return price_arr[1];
})
await nightmare.end();
console.log(`Buy: ${buyResult}`);
console.log(`Sell: ${sellResult}`);
return [buyResult, sellResult]
} catch(err) {
throw err;
}
}
};