diff --git a/scraper/src/main.js b/scraper/src/main.js index dea15f69..29276f53 100644 --- a/scraper/src/main.js +++ b/scraper/src/main.js @@ -1,6 +1,7 @@ import Fastify from 'fastify' import cors from '@fastify/cors' import scrapeData from './scraper'; +import loadWebsite from './load'; const fastify = Fastify(); @@ -15,6 +16,17 @@ fastify.get('/', async (request, reply) => { reply.send('Vroom Vroom Vroom'); }); +fastify.post('/load-website', async (request, reply) => { + const { url } = request.body; + try { + const response = await loadWebsite(url); + reply.send(response); + console.log('Response is::', response) + } catch (error) { + reply.status(500).send({ error: error }); + } +}); + fastify.post('/scrape', async (request, reply) => { const { url, selectors } = request.body; try {