-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
135 lines (125 loc) · 5.05 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
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
const fetch = require('node-fetch')
const fs = require('fs-extra')
const delay = require('delay')
const moment = require('moment')
const cheerio = require('cheerio')
const cheerioTableparser = require('cheerio-tableparser')
require('colors')
/**
* Global Variable
*/
let watcherKeyword = ['.finance'], thresholdPrice = '$0 - $1', thresholdHolder = 50
let timeoutTimer = 10000
/**
* Banner Header
*/
let bannerHeader = `
_
| |__ ___ ___ ___ ___ __ _ _ __ ___ ___ _ __ ___
| '_ \\/ __|/ __/ __|/ __/ _\` | '_ \\ / __/ _ \\| ' \` _ \\
| |_) \\__ \\ (__\\__ \\ (_| (_| | | | || (_| (_) | | | | | |
|_.__/|___/\\___|___/\\___\\__,_|_| |_(_)___\\___/|_| |_| |_|
** Shitcoin - Token Tracker and Monitoring by @cdw1p **
++ Bot Configuration
- Loaded Keyword\t: ${watcherKeyword.length}
- Threshold Price\t: ${thresholdPrice}
- Threshold Holder\t: ${thresholdHolder} Address
- Alert Notification\t: Telegram Channel
`
/**
* Find BSC Tokens
*/
const functionFindBSCToken = () => new Promise(async (resolve, reject) => {
try {
let tempData = []
let currentPage = 1
let customPayload = {
method: 'GET',
timeout: timeoutTimer,
headers: {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36',
}
}
let totalData = cheerio.load(await (await fetch(`https://bscscan.com/tokens?q=${watcherKeyword[0]}&p=1`, customPayload)).text())('#ContentPlaceHolder1_divPagination > ul > li:nth-child(3) > span > strong:nth-child(2)').text()
for (loop = 1; loop < totalData; loop++) {
await delay(5 * 1000)
await fetch(`https://bscscan.com/tokens?q=${watcherKeyword[0]}&p=${currentPage}`, customPayload)
.then(res => res.text())
.then(result => {
const $ = cheerio.load(result)
cheerioTableparser($)
const dataParse = $('table').parsetable(true, true, true)
const [ tokenContract, tokenName, tokenSymbol, tokenDecimals, tokenSite ] = dataParse
for (let index = 0; index < tokenContract.length; index++) {
tempData.push({
tokenContract: tokenContract[index],
tokenName: tokenName[index],
tokenSymbol: tokenSymbol[index],
tokenDecimals: tokenDecimals[index],
tokenSite: tokenSite[index]
})
}
currentPage += 1
})
}
tempData = tempData.filter(data => data.tokenSite.includes('https://'))
console.log(`(${moment().format('HH:mm:ss')}) Found: ${tempData.length} Data`)
resolve({ success: true, message: tempData })
} catch (err) {
resolve({ success: false, message: err.message })
}
})
/**
* Find BSC Info
*/
const functionFindBSCInfo = (tokenData) => new Promise(async (resolve, reject) => {
try {
let tempData = []
let customPayload = {
method: 'GET',
timeout: timeoutTimer,
headers: {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36',
}
}
for (data of tokenData) {
const { tokenContract, tokenName, tokenSymbol, tokenDecimals, tokenSite } = data
fetch(`https://bscscan.com/token/${tokenContract}`, customPayload)
.then(res => res.text())
.then(result => {
const $ = cheerio.load(result)
const tokenPrice = ($('#ContentPlaceHolder1_tr_valuepertoken > div > div:nth-child(1) > span').text()).split(' @ ')[0].split('$')[1]
const tokenHolders = ($('#ContentPlaceHolder1_tr_tokenHolders > div > div.col-md-8 > div > div').text()).split(' addresses')[0].replace(',', '')
if (parseFloat(tokenPrice) <= parseFloat(thresholdPrice.split(' - $')[1]) && parseFloat(tokenHolders) >= parseFloat(thresholdHolder)) {
console.log(`${`++ Token Found : ${tokenName} (${tokenSymbol}) - $${tokenPrice}`.green}\n - Contract: ${tokenContract}\n - Website: ${tokenSite}\n - Holder: ${tokenHolders.trim()} Address\n -`)
tempData.push({ tokenContract, tokenName, tokenSymbol, tokenDecimals, tokenSite, tokenPrice: `$${tokenPrice}`, tokenHolders: tokenHolders.trim() })
} else {
console.log(`${`++ Skipping : ${tokenName} (${tokenSymbol}) - $${tokenPrice}`.yellow}\n - Contract: ${tokenContract}\n - Website: ${tokenSite}\n - Holder: ${tokenHolders.trim()} Address\n -`)
}
})
await delay(5 * 1000)
}
resolve({ success: true, message: tempData })
} catch (err) {
resolve({ success: false, message: err.message })
}
})
/**
* Main Function
*/
;(async () => {
try {
console.log(bannerHeader)
const resFindBSCToken = await functionFindBSCToken()
if (resFindBSCToken.success) {
const resFindBSCInfo = await functionFindBSCInfo(resFindBSCToken.message)
if (resFindBSCInfo.success) {
await fs.writeFileSync('output.json', JSON.stringify(resFindBSCInfo.message, null, 2))
}
} else {
throw new Error(resFindBSCToken.message)
}
} catch (err) {
console.log(`Error: ${err.message}`.red)
}
})()