From 528d8249a742f8d3a9bef4749ebd7e054a177351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roggeri=20Campos?= Date: Mon, 5 Feb 2024 12:19:06 -0300 Subject: [PATCH] fix: Account statements Closes #219 --- pyitau/pages.py | 16 +- .../checking_account_full_statement.html | 199 ++++++++++++++---- 2 files changed, 163 insertions(+), 52 deletions(-) diff --git a/pyitau/pages.py b/pyitau/pages.py index 08d0ca9..ed6a8b4 100644 --- a/pyitau/pages.py +++ b/pyitau/pages.py @@ -237,23 +237,15 @@ def first_card_id(self): class CheckingAccountFullStatement(TextPage): + _url_pattern = 'url\s*=\s*"([^"]*)";' + @property def filter_statements_by_period_op(self): - pattern = ( - r"function consultarLancamentosPorPeriodo.*" - r'"periodoConsulta" : parametrosPeriodo.*?' - r'url = "(.*?)";' - ) - return re.search(pattern, self._text, flags=re.DOTALL).group(1) + return re.findall(self._url_pattern, self._text, flags=re.DOTALL)[2] @property def filter_statements_by_month_op(self): - pattern = ( - r"function consultarLancamentosPorPeriodo.*" - r'"mesCompleto" : parametrosPeriodo.*?' - r'url = "(.*?)";' - ) - return re.search(pattern, self._text, flags=re.DOTALL).group(1) + return re.findall(self._url_pattern, self._text, flags=re.DOTALL)[1] class CardDetails(TextPage): diff --git a/tests/responses/checking_account_full_statement.html b/tests/responses/checking_account_full_statement.html index e905bd0..ccd0932 100644 --- a/tests/responses/checking_account_full_statement.html +++ b/tests/responses/checking_account_full_statement.html @@ -1,42 +1,161 @@