chore: lint
This commit is contained in:
@@ -200,7 +200,7 @@ async function clickNextPagination(selector, scrapedData, limit) {
|
||||
throw new Error("No more items to load or pagination has ended.");
|
||||
}
|
||||
|
||||
//return clicked; // Indicate whether pagination occurred
|
||||
return clicked; // Indicate whether pagination occurred
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +355,6 @@ async function clickNextPagination(selector, scrapedData, limit) {
|
||||
for (const [label, { selector, attribute }] of Object.entries(fields)) {
|
||||
const fieldElement = parent.querySelector(selector);
|
||||
|
||||
// Depending on the attribute specified, extract the data
|
||||
if (fieldElement) {
|
||||
if (attribute === 'innerText') {
|
||||
record[label] = fieldElement.innerText.trim();
|
||||
@@ -366,7 +365,6 @@ async function clickNextPagination(selector, scrapedData, limit) {
|
||||
} else if (attribute === 'href') {
|
||||
record[label] = fieldElement.href;
|
||||
} else {
|
||||
// Default to attribute retrieval
|
||||
record[label] = fieldElement.getAttribute(attribute);
|
||||
}
|
||||
}
|
||||
@@ -376,19 +374,25 @@ async function clickNextPagination(selector, scrapedData, limit) {
|
||||
scrapedData.push(record);
|
||||
}
|
||||
|
||||
// Check if we need to paginate
|
||||
if (pagination && scrapedData.length < limit) {
|
||||
let paginated = false;
|
||||
|
||||
switch (pagination.type) {
|
||||
case 'scrollDown':
|
||||
await scrollDownToLoadMore(listSelector, limit);
|
||||
paginated = true;
|
||||
break;
|
||||
case 'scrollUp':
|
||||
await scrollUpToLoadMore(listSelector, limit);
|
||||
paginated = true;
|
||||
break;
|
||||
case 'clickNext':
|
||||
await clickNextPagination(pagination.selector, scrapedData, limit);
|
||||
paginated = await clickNextPagination(pagination.selector, scrapedData, limit);
|
||||
break;
|
||||
case 'clickLoadMore':
|
||||
//await clickLoadMorePagination(pagination.selector);
|
||||
//paginated = true;
|
||||
break;
|
||||
case 'none':
|
||||
// No more items to load
|
||||
@@ -397,7 +401,12 @@ async function clickNextPagination(selector, scrapedData, limit) {
|
||||
console.warn("Unknown pagination type");
|
||||
break;
|
||||
}
|
||||
|
||||
if (paginated) {
|
||||
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait for content to load
|
||||
} else {
|
||||
break; // No further pagination needed
|
||||
}
|
||||
} else {
|
||||
break; // No more items to load or no pagination
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user