import axios from 'axios';
import * as cheerio from 'cheerio';
export async function scrapeText(url) {
try {
const response = await axios.get(url, {
timeout: 5000,
headers: { 'User-Agent': 'Mozilla/5.0' }
});
const $ = cheerio.load(response.data);
$('script, style, nav, footer, header').remove();
return $('body').text().replace(/\s+/g, ' ').trim().substring(0, 3000);
} catch (err) {
return '';
}
}