From ed5dd602ac6ec42dc216513ee561597078eaa535 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sun, 21 Apr 2024 19:51:19 +0530 Subject: [PATCH] feat: load website html route --- scraper/src/main.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 {