From 73c678774fb2d78e03ff7cb7dbe4676864f3c852 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Tue, 16 Apr 2024 23:48:32 +0530 Subject: [PATCH] feat: scrape route --- scraper/src/main.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scraper/src/main.js b/scraper/src/main.js index 6b2df41a..c5e93417 100644 --- a/scraper/src/main.js +++ b/scraper/src/main.js @@ -1,5 +1,8 @@ const fastify = require('fastify')(); const scraper = require('./scraper'); +const fetch = require('node-fetch'); + + // Change this later const corsOptions = { origin: 'http://localhost:5173' @@ -8,10 +11,10 @@ fastify.register(require('@fastify/cors'), corsOptions) fastify.post('/scrape', async (request, reply) => { - const { url, selections } = request.body; + const { url, selectors } = request.body; try { - const data = await scraper.scrape(url, selections); + const data = await scraper(url, selectors); console.log('Scraped data:', data); reply.send(data); } catch (error) {