aboutsummaryrefslogtreecommitdiffstats
path: root/python/download_scotia.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/download_scotia.py')
-rw-r--r--python/download_scotia.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/python/download_scotia.py b/python/download_scotia.py
index 1f5cbb8e..df3b874d 100644
--- a/python/download_scotia.py
+++ b/python/download_scotia.py
@@ -22,6 +22,18 @@ def wait(driver):
def download_report(account_username, password, report_dir):
driver = create_driver(report_dir)
+ login(driver, account_username, password)
+ navigate_to_inbox(driver)
+ attachment_element = get_attachment_element(driver)
+ fname = attachment_element.text.split()[0]
+ if not os.path.exists(os.path.join(report_dir, fname)):
+ attachment_element.click()
+ else:
+ logging.info(f"{fname} already exists in {report_dir}")
+ driver.quit()
+
+
+def login(driver, account_username, password):
driver.get("https://web1.mail.scotiabank.com/webmail/do/Home")
wait(driver)
username_element = driver.find_element_by_id("username")
@@ -31,6 +43,9 @@ def download_report(account_username, password, report_dir):
login_button = driver.find_element_by_id("loginbutton")
login_button.click()
wait(driver)
+
+
+def navigate_to_inbox(driver):
time.sleep(1)
login_button = driver.find_element_by_id("leftNavFolderLink")
login_button.click()
@@ -41,14 +56,10 @@ def download_report(account_username, password, report_dir):
elements = driver.find_elements_by_class_name("zfolder-msg-clickable")[0]
elements.click()
time.sleep(1)
- elements = driver.find_elements_by_class_name("zmessage-attachment-link")[0]
- fname = elements.text.split()[0]
- # check if the file exists in the directory
- if not os.path.exists(os.path.join(report_dir, fname)):
- elements.click()
- else:
- logging.info(f"{fname} exists already in {report_dir}")
- driver.quit()
+
+
+def get_attachment_element(driver):
+ return driver.find_elements_by_class_name("zmessage-attachment-link")[0]
def create_driver(download_dir):
@@ -64,7 +75,6 @@ def create_driver(download_dir):
def main():
-
scotia_login = {"selene-ops@lmcg.com": "oeujG*UF!53o"}
for username, password in scotia_login.items():
REPORT_DIR = DAILY_DIR / "Selene" / "Scotia_reports"