I am scraping some data from a webiste using cheerio. I get the output I want in the console, but not in my node.
I am scraping the price on this website: https://www.coindesk.com/price/bitcoin-sv/
In the console, this is working:
$('div[class="sc-bxivhb cNnmSt"] span[class="Typography__StyledTypography-sc-1xaoczh-0 euSZAS"]').textContent
When I run it in the node I write: $('div[class="sc-bxivhb cNnmSt"] span[class="Typography__StyledTypography-sc-1xaoczh-0 euSZAS"]').text() but its not working.
Anyone know why?
The page you are trying to scrape is generated with JavaScript. If you look into view-source:https://www.coindesk.com/price/bitcoin-sv/ you will look mostly JavaScript and not so much HTML. cheerio cannot run JavaScript, it just parses static source code.
You need something like https://github.com/puppeteer/puppeteer to get JS-generated content.