javascriptpythonhtmlnode.jssmartcontracts

How can know new token(smart contract) except https://www.defined.fi/new?


I want to get name lists of new token more faster than Defined.fi/new

I am knowing just Defined.fi/new. but more than faster, which web site or scrape tool do I have to use ? For new token listing, I'd like to get names by scraping tool or program. can you please help me ?


Solution

  • I think you can get new token lists easily using node.js. there are my worked.

    const puppeteer = require('puppeteer-extra');
    const StealthPlugin = require('puppeteer-extra-plugin-stealth');
    
    // Use stealth plugin to avoid detection
    puppeteer.use(StealthPlugin());
    
    (async () => {
        const url = 'https://www.defined.fi/new';
    
        const chromePath = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe';
        const userDataDir = 'C:\\Users\\<YourUsername>\\AppData\\Local\\Google\\Chrome\\User Data\\Default';
    
        // Launch Puppeteer with your existing Chrome profile
        const browser = await puppeteer.launch({
            headless: true, 
            executablePath: chromePath, 
            args: [
                `--user-data-dir=${userDataDir}`, 
                '--start-maximized', 
                '--disable-blink-features=AutomationControlled',
            ],
        });
    
        const page = await browser.newPage();
        
        await page.goto(url, { waitUntil: 'networkidle0', timeout: 0 }); // No timeout        
    
        try {
            async function monitorElements(page, elementSelector) {
                let intervalID;
    
                try {
                    intervalID = setInterval(async () => {
                        try {
                            const elements = await page.$$(elementSelector);
                            if (elements.length >= 2) {
                                await elements[1].hover();
                            }
                        } catch (error) {                            
                        }
                    }, 3001);
                } catch (error) {
                }
                    
                process.on("SIGINT", () => {
                    clearInterval(intervalID);                    
                    process.exit(0);
                });
            }    
            
            await page.exposeFunction("processTooltip", (tooltipText) => {
                const matches = [...tooltipText.matchAll(/([a-zA-Z ]+)([\d.,]+[KMGTBQ]?)/g)];
                const formattedTooltip = matches.map(([_, key, value]) => `${key.trim()}: ${value.trim()}`);                
    
                matches.forEach(([_, key, value]) => {
                    const numericValue = parseFloat(
                        value.replace(/,/g, "").replace("M", "e6").replace("B", "e9")
                    ); 
                });
            });
    
            // Monitor tooltips dynamically using MutationObserver
            await page.evaluate(() => {
                const observer = new MutationObserver((mutations) => {
                    mutations.forEach((mutation) => {
                        mutation.addedNodes.forEach((node) => {
                            if (node.nodeType === 1 && node.matches('div[role="tooltip"]')) {
                                setTimeout(() => {
                                    window.processTooltip(node.textContent.trim());
                                }, 500); 
                            }
                        });
                    });
                });
    
                observer.observe(document.body, { childList: true, subtree: true });
                console.log("Observer initialized. Waiting for tooltips...");
            });
    
            const elementSelector = '.cell-inner .MuiTypography-root[data-sentry-element="EllipsisText"]';
            await monitorElements(page, elementSelector);
        } catch (error) {
            console.error('Error occurred:', error);
        } finally {
            // Uncomment this to close the browser after testing
            // await browser.close();
        }
    })();