Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(beinleumi): account with no balance (inactive) #893

Merged
merged 4 commits into from
Jan 16, 2025

Conversation

whatuserever
Copy link
Contributor

@whatuserever whatuserever commented Jan 12, 2025

In Beinleumi, inactive accounts expectedly do no have a balance. See the comparison below between an active and inactive accounts.

This PR fixes #892 by making the balance optional for Beinleumi

Active

image

Inactive

image

Test

Ran the scraper and printed scrapeResult.accounts

Before

Error: failed to find element matching selector ".main_balance"

After

[
  {
    accountNumber: '1',
    txns: [ [Object], [Object], [Object], [Object], [Object] ],
    balance: 12345.67
  },
  { accountNumber: '2', txns: [], balance: undefined }
]

@whatuserever
Copy link
Contributor Author

@baruchiro could you please review 🙏

Comment on lines 261 to 267
const balanceElement = await page.$(CURRENT_BALANCE);
if (!balanceElement) {
return undefined;
}
const balanceStr = await page.$eval(CURRENT_BALANCE, (option) => {
return (option as HTMLElement).innerText;
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know your JS Scraping experience, but do you think once you have a reference to the balanceElement, get its innerText (instead of using eval again on the same selector)?

Copy link
Contributor Author

@whatuserever whatuserever Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no experience at all with either JS or scraping 🙃

I looked at the Puppeteer docs now, and it looks like we can do balanceElement.evaluate. I tested this and it works.

This is still another evaluation, though. But I guess it's slightly more efficient as it shouldn't be searching for the element in the entire page? Not sure tbh.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You see, it is not so important, and I don't think efficiency is critical here.

But it is less confusing, and the code is more straightforward—find an element, and if it exists, take its innerText.

@baruchiro
Copy link
Collaborator

@whatuserever Can I register you as a tester for Beinleumi? #830

@baruchiro baruchiro merged commit 26837de into eshaham:master Jan 16, 2025
5 checks passed
Copy link

🎉 This PR is included in version 5.2.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@whatuserever
Copy link
Contributor Author

Sure

@whatuserever whatuserever deleted the beinleumi-no-balance branch January 16, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Beinleumi: failed to find element matching selector ".main_balance"
2 participants