Compare commits

...

2 commits

Author SHA1 Message Date
43b76772e1 update readme 2024-10-14 19:58:25 +02:00
8ef7829b73 implement download from new lcl interface 2024-10-14 19:55:37 +02:00
6 changed files with 24 additions and 17 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
error_download_lcl.png
geckodriver.log
# Created by https://www.gitignore.io/api/osx,pycharm,python

View file

@ -1 +1,2 @@
python 3.11.2
poetry latest

View file

@ -50,7 +50,7 @@ inv full-test
poetry version <major/minor/patch>
git add .
git commit
inv tag <version>
inv tag $(poetry version -s)
inv publish publish-docker
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

View file

@ -1,4 +1,4 @@
import os
import datetime
import time
from pathlib import Path
@ -27,7 +27,7 @@ class LclDownloader:
download_folder = Path.home() / "Downloads"
self.download_folder = download_folder.resolve()
options = webdriver.FirefoxOptions()
options.headless = True
options.add_argument("-headless")
options.set_preference("browser.download.dir", str(self.download_folder))
options.set_preference(
"browser.helperApps.neverAsk.saveToDisk", "application/x-ofx"
@ -72,20 +72,19 @@ class LclDownloader:
click.secho("No welcome screen found.", fg="blue")
retry = False
try:
self._click(By.CSS_SELECTOR, ".burger-menu-content")
self._click(By.CSS_SELECTOR, ".return-legacy-button")
click.secho("Going back to legacy version...", fg="blue")
except NoSuchElementException:
click.secho("Probably already on legacy version.", fg="blue")
self._click(By.CLASS_NAME, "extended-zone")
self._click(By.ID, "export-button")
click.secho("Navigating through archives...", fg="blue")
self._click(By.ID, "linkSynthese")
self._click(By.CLASS_NAME, "picDl")
self._select(By.ID, "change", index=1)
self._select(By.ID, "DS", index=20)
self._click(By.ID, "MON04")
self._click(By.ID, "Valider")
end = datetime.date.today() - datetime.timedelta(days=1)
start = end - datetime.timedelta(days=9)
self._type_nth(By.CSS_SELECTOR, "input.range-picker-input", 0, start.strftime("%d/%m/%Y"))
self._type_nth(By.CSS_SELECTOR, "input.range-picker-input", 1, end.strftime("%d/%m/%Y"))
self._click(By.CSS_SELECTOR, "ui-desktop-select button")
self._click_nth(By.CSS_SELECTOR, "ui-select-list ul li", 2)
self._click(By.CLASS_NAME, "download-button")
click.secho("Found it!", fg="green")
selenium.get("about:downloads")
return self._get_last_download_file_name()
@ -93,9 +92,15 @@ class LclDownloader:
def _click(self, by: By, value: str):
self.selenium.find_element(by, value).click()
def _click_nth(self, by: By, value: str, idx: int):
self.selenium.find_elements(by, value)[idx].click()
def _select(self, by: By, value: str, index: int):
Select(self.selenium.find_element(by, value)).select_by_index(index)
def _type_nth(self, by: By, value: str, idx: int, value_to_type: str):
self.selenium.find_elements(by, value)[idx].send_keys(value_to_type)
def _get_last_download_file_name(self, wait_seconds: int = 30):
end_time = time.time() + wait_seconds
while time.time() < end_time:

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "ofx-processor"
version = "4.4.6"
version = "4.5.0"
description = "Personal ofx processor"
readme = "README.md"
authors = ["Gabriel Augendre <gabriel@augendre.info>"]