Lyrics ins't returning nothing.
Use this code to solve this:
import axios from "axios";
import { load } from "cheerio";
const scrapeLyrics = async (url) => {
try {
const { data } = await axios.get(url);
const $ = load(data);
let lyrics = "";
$("div[data-lyrics-container]").each((i, elem) => {
const snippet = $(elem)
.html()
.replace(/<br\s*\/?>/g, "\n")
.replace(/<[^>]+>/g, "");
lyrics += snippet.trim() + "\n\n";
});
if (!lyrics) {
console.log("No letters found.");
return null;
}
return lyrics.trim();
} catch (error) {
console.error("Error while scraping:", error.message);
return null;
}
};
const lyrics = await scrapeLyrics(result.url);
Lyrics ins't returning nothing.
Use this code to solve this: