Spaces:
Paused
Paused
File size: 594 Bytes
05abd64 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import scrapeService from '../services/scrape.service.js';
class ScrapeController {
async scrape(req, res) {
try {
const { url } = req.body;
if (!url) {
return res.status(400).json({ error: 'URL is required' });
}
const data = await scrapeService.scrapeUrl(url);
res.json(data);
} catch (error) {
console.error('Scrape Error:', error.message);
res.status(500).json({
error: 'Failed to scrape URL',
details: error.message
});
}
}
}
export default new ScrapeController();
|