import axios from 'axios'; import cheerio from 'cheerio'; async function getMetaData(url) { try { const response = await axios.get(url); const html = response.data; const $ = cheerio.load(html); const title = $('meta[property="og:title"]').attr('content'); const description = $('meta[property="og:description"]').attr('content'); const image = $('meta[property="og:image"]').attr('content'); return { title: title || 'No title', description: description || 'No description', image: image || '' }; } catch (error) { console.error('Error fetching URL:', error.message); return {}; } } export { getMetaData };