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

AttributeError: 'NoneType' object has no attribute 'group' #219

Open
danhenriquesc opened this issue Feb 4, 2024 · 3 comments · Fixed by #220
Open

AttributeError: 'NoneType' object has no attribute 'group' #219

danhenriquesc opened this issue Feb 4, 2024 · 3 comments · Fixed by #220

Comments

@danhenriquesc
Copy link

Since yesterday I started receiving the following error when loading account statement

Traceback (most recent call last):
  File "/Users/danielcosta/Documents/Projects/FinanceControl/./main.py", line 49, in <module>
    itau_bank_account_transactions = get_itau_bank_account_expenses(itau_account, month, year)
  File "/Users/danielcosta/Documents/Projects/FinanceControl/itau_bank_account.py", line 8, in get_itau_bank_account_expenses
    statement = itau_account.get_statements_from_month(month=month, year=year)
  File "/Users/danielcosta/Library/Python/3.9/lib/python/site-packages/pyitau/main.py", line 101, in get_statements_from_month
    "op": self._checking_full_statement_page.filter_statements_by_month_op
  File "/Users/danielcosta/Library/Python/3.9/lib/python/site-packages/pyitau/pages.py", line 256, in filter_statements_by_month_op
    return re.search(pattern, self._text, flags=re.DOTALL).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
@rodrimaia
Copy link

rodrimaia commented Feb 5, 2024

+1 facing the same issue. (only for checking account, credit card still working fine)

andreroggeri added a commit to andreroggeri/pyitau that referenced this issue Feb 5, 2024
andreroggeri added a commit to andreroggeri/pyitau that referenced this issue Feb 6, 2024
@FernandoGaspar
Copy link

FernandoGaspar commented Feb 6, 2024

Now I'm getting this error:
"[222] @Property
def full_statement_op(self):
return self._soup.find("a").attrs["data-op"]

KeyError: 'data-op''"
Does anyone know what could be causing this?

lucasrcezimbra added a commit that referenced this issue Feb 9, 2024
* fix: Account statements
Closes #219

* Update pyitau/pages.py

---------

Co-authored-by: Lucas Rangel Cezimbra <[email protected]>
@rodrimaia
Copy link

So, even after the new release, I still had the same issue as @FernandoGaspar mentioned.

After debugging for a while, I realized the find("a") returns only the first item on that Menu, which doesn't have the data-op attribute. I don't know if Itau switched the menu order or something, but I realized the second item on that menu was exactly what we were looking for at that time. So I locally just changed to use the second link:

return self._soup.find_all("a")[1].attrs["data-op"]

I am aware this is not the most reliable solution, so maybe would be nice to filter all the links on that menu to find the one which has the link to the statements page (using the link name/title maybe??). if you guys have any idea how to do the filtering I would be happy to open a PR for it.

@FernandoGaspar can you try the same patch and see if it fixes the issue for you?

@lucasrcezimbra lucasrcezimbra reopened this Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants