From eabe62fff7b05b5d7543d1aca842c9020d1b7ad7 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 3 Aug 2024 20:45:37 +0530 Subject: [PATCH] fix: preserve original key structure --- maxun-core/src/browserSide/scraper.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/maxun-core/src/browserSide/scraper.js b/maxun-core/src/browserSide/scraper.js index 3911565f..9c9182d5 100644 --- a/maxun-core/src/browserSide/scraper.js +++ b/maxun-core/src/browserSide/scraper.js @@ -182,7 +182,7 @@ function scrapableHeuristics(maxCountPerPage = 50, minArea = 20000, scrolls = 3, return crudeRecords; }; - /** +/** * Given an object with named lists of elements, * groups the elements by their distance in the DOM tree. * @param {Object.} lists The named lists of HTML elements. @@ -229,11 +229,11 @@ window.scrapeSchema = function (lists) { return MBEs.map((mbe) => omap( lists, - ({ selector }) => { + ({ selector }, key) => { const elem = Array.from(document.querySelectorAll(selector)).find((elem) => mbe.contains(elem)); return elem ? elem.innerText : undefined; }, - (key) => lists[key].selector // Use the selector as the key in the output + (key) => key // Use the original key in the output )); }