feat: limit no. of records scraped

This commit is contained in:
karishmas6
2024-08-13 23:49:10 +05:30
parent 00d32571fb
commit 448ffbfc05

View File

@@ -278,9 +278,9 @@ async function scrollDownToLoadMore(selector, limit) {
* @param {boolean} [config.flexible=false] - Whether to use flexible matching for field selectors
* @returns {Array.<Array.<Object>>} Array of arrays of scraped items, one sub-array per list
*/
window.scrapeList = function ({ listSelector, fields }) {
window.scrapeList = function ({ listSelector, fields, limit = 10 }) {
// Get all parent elements matching the listSelector
const parentElements = Array.from(document.querySelectorAll(listSelector));
const parentElements = Array.from(document.querySelectorAll(listSelector)).slice(0, limit);
const scrapedData = [];