From 201b9fff6ce0601e25dad391a0880ff490ef25ae Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Tue, 16 Apr 2024 22:38:27 +0530 Subject: [PATCH] feat: visual selection (wip) --- ui/src/components/Scraper/index.jsx | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/ui/src/components/Scraper/index.jsx b/ui/src/components/Scraper/index.jsx index dfb27288..b6ba4292 100644 --- a/ui/src/components/Scraper/index.jsx +++ b/ui/src/components/Scraper/index.jsx @@ -1,10 +1,12 @@ -import React, { useState } from 'react'; +import React, { useState, useRef, useEffect } from 'react'; import axios from 'axios'; +import Frame from 'react-frame-component'; function Scraper() { const [url, setUrl] = useState(''); const [selections, setSelections] = useState([]); const [data, setData] = useState(null); + const iframeRef = useRef(null); const handleUrlChange = (e) => { setUrl(e.target.value); @@ -55,6 +57,22 @@ function Scraper() { } }; + // useEffect(() => { + // if (iframeRef.current && iframeRef.current.contentWindow) { + // const contentWindow = iframeRef.current.contentWindow; + // const contentDocument = contentWindow.document; + + // contentDocument.body.onclick = handleSelectElement; + // } + // }, [url]); + + const handleIframeLoad = () => { + if (iframeRef.current && iframeRef.current.contentDocument) { + const contentDocument = iframeRef.current.contentDocument; + contentDocument.body.onclick = handleSelectElement; + } + }; + return (
Scrape

Click on the elements you want to scrape: