Skip to content

Instantly share code, notes, and snippets.

@kami4ka
Created November 24, 2021 20:44
Show Gist options
  • Save kami4ka/622ce5e3046cee793dc3d38ad9195f28 to your computer and use it in GitHub Desktop.
Save kami4ka/622ce5e3046cee793dc3d38ad9195f28 to your computer and use it in GitHub Desktop.
Scrape Dextools token price using ScrapingAnt API
/**
* Get data from MCC DexTools token listing
*
* ScrapingAnt allows you to scrape for free using proxy servers
*
* npm install @scrapingant/scrapingant-client
* npm install cheerio
**/
const cheerio = require('cheerio');
const ScrapingAnt = require('@scrapingant/scrapingant-client');
const API_KEY = '<SCRAPINGANT_API_KEY>';
// Place a desired token URL
const TOKEN_URL = 'https://www.dextools.io/app/ether/pair-explorer/0xdca79f1f78b866988081de8a06f92b5e5d316857';
const client = new ScrapingAnt({ apiKey: API_KEY });
main()
.then(console.log)
.catch(console.error);
async function main() {
// Get MCC toke price
const tokensResponse = await client.scrape(TOKEN_URL, { wait_for_selector: '.pair-price' });
const $ = cheerio.load(tokensResponse.content)
const price = $('.pair-price').text()
return price;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment