Skip to content

Commit

Permalink
fix: fixed a bug where internal pagecount was increased by one
Browse files Browse the repository at this point in the history
So the scraping always starts with the seconds page. Amazon uses zero based paginations.
  • Loading branch information
Disane87 committed Oct 31, 2024
1 parent 5227f00 commit e50762a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/commands/scrape/amazon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ export default class Amazon extends ScrapeCommand<typeof Amazon> {
}
this.logger.debug(`Got ${orderPageCount} for year ${currentYear}`);

for (const orderPage of [...Array(orderPageCount).keys()].map(pageNo => pageNo + 1)) {
for (const orderPage of [...Array(orderPageCount).keys()].map(pageNo => pageNo)) {
if (this.options.pageFilter && orderPage != this.options.pageFilter) {
this.logger.info(`Skipping page ${orderPage} due to page filter`);
continue;
}

this.logger.info(`Processing page ${orderPage}`);
this.logger.info(`Processing page ${orderPage + 1}`);
await this.goToYearAndPage(currentYear, orderPage, this.definition);
const onlyNewInvoiceHandled = await this.processOrderPage(orderPage, processedOrders);
if (onlyNewInvoiceHandled) {
Expand All @@ -141,7 +141,7 @@ export default class Amazon extends ScrapeCommand<typeof Amazon> {
}

private async processOrderPage(orderPage: number, processedOrders: Scrape[]): Promise<boolean> {
this.logger.info(`Checking page ${orderPage} for orders`);
this.logger.info(`Checking page ${orderPage + 1} for orders`);
const orderCards = await this.currentPage.$$(this.selectors.orderCards);
this.logger.info(`Got ${orderCards.length} orders. Processing...`);

Expand Down

0 comments on commit e50762a

Please sign in to comment.