import cheerio from "cheerio";

const html = `<div class="SdParagraph-sc-u7u53k jsmdIZ"><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">Around</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span>250</span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">million</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">years</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">ago</span><span>,</span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span>700</span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">species</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">of</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">reptiles</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">closely</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">related</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">to</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">the</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">modern-day</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">crocodile</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">roamed</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">the</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">earth</span><span>,</span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">now</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">new</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">research</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">reveals</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">how</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">a</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">complex</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">interplay</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">between</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">climate</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">change</span><span>,</span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">species</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">competition</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">and</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">habitat</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">can</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">help</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">explain</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">why</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">just</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span>23</span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">species</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">of</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">crocodile</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">survive</span><span></span></span><span style="font-size: 1.15rem; line-height: 2; margin-right: 5px;"><span></span><span class="WordContainer-sc-5mz3e2 kunCRD">today</span><span>.</span></span><div class="SdPlayButtonContainer-sc-sjxlmp KxeOq"><button type="button" class="ant-btn ant-btn-primary ant-btn-circle ant-btn-sm ant-btn-icon-only ant-btn-background-ghost"><i aria-label="icon: sound" class="anticon anticon-sound"><svg viewBox="64 64 896 896" class="" data-icon="sound" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false"><path d="M625.9 115c-5.9 0-11.9 1.6-17.4 5.3L254 352H90c-8.8 0-16 7.2-16 16v288c0 8.8 7.2 16 16 16h164l354.5 231.7c5.5 3.6 11.6 5.3 17.4 5.3 16.7 0 32.1-13.3 32.1-32.1V147.1c0-18.8-15.4-32.1-32.1-32.1zM586 803L293.4 611.7l-18-11.7H146V424h129.4l17.9-11.7L586 221v582zm348-327H806c-8.8 0-16 7.2-16 16v40c0 8.8 7.2 16 16 16h128c8.8 0 16-7.2 16-16v-40c0-8.8-7.2-16-16-16zm-41.9 261.8l-110.3-63.7a15.9 15.9 0 0 0-21.7 5.9l-19.9 34.5c-4.4 7.6-1.8 17.4 5.8 21.8L856.3 800a15.9 15.9 0 0 0 21.7-5.9l19.9-34.5c4.4-7.6 1.7-17.4-5.8-21.8zM760 344a15.9 15.9 0 0 0 21.7 5.9L892 286.2c7.6-4.4 10.2-14.2 5.8-21.8L878 230a15.9 15.9 0 0 0-21.7-5.9L746 287.8a15.99 15.99 0 0 0-5.8 21.8L760 344z"></path></svg></i></button></div></div>
`;

// Load the HTML using cheerio
const $ = cheerio.load(html);

// Extract text content and concatenate spans
let extractedText = "";
$('.SdParagraph-sc-u7u53k').find('span').each((index, element) => {
    extractedText += `${$(element).text().trim()} `;
});

// Remove extra whitespace
extractedText = extractedText.trim().replace(/\s+/g, ' ');

console.log(extractedText); """getting Around Around 250 250 million million years years ago, ago , 700 700 species species of of reptiles reptiles closely closely related related to to the the modern-day modern-day crocodile crocodile roamed roamed the the earth, earth , now now new new research research reveals reveals how how a a complex complex interplay interplay between between climate climate change, change , species species competition competition and and habitat habitat can can help help explain explain why why just just 23 23 species species of of crocodile crocodile survive survive today. today ."""