-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrugcheck.js
33 lines (27 loc) · 1.1 KB
/
rugcheck.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
const axios = require('axios');
const cheerio = require('cheerio'); // Web scraping library
async function getDexScreenerData(tokenMint) {
const url = `https://dexscreener.com/solana/${tokenMint}`;
try {
const { data } = await axios.get(url);
const $ = cheerio.load(data);
let liquidity = $('div:contains("Liquidity")').next().text();
let volume24h = $('div:contains("24H Volume")').next().text();
let buys = $('div:contains("Buys")').next().text();
let sells = $('div:contains("Sells")').next().text();
liquidity = liquidity.replace(/\$|,/g, '') || "0"; // Convert to number
volume24h = volume24h.replace(/\$|,/g, '') || "0"; // Convert to number
buys = parseInt(buys) || 0;
sells = parseInt(sells) || 0;
return {
liquidity: parseFloat(liquidity),
volume24h: parseFloat(volume24h),
buys,
sells
};
} catch (error) {
console.error("Failed to fetch DexScreener data:", error.message);
return null;
}
}
module.exports = { getDexScreenerData };