def fetch_latest_bill(driver: webdriver.remote.webdriver.WebDriver) -> bytes: driver.get('https://one.viseca.ch/de/rechnungen') driver.implicitly_wait(30) latest_bill_a_elem = driver.find_element( By.CSS_SELECTOR, '#statement-list-statement-date0 a') latest_bill_id = extract_bid(latest_bill_a_elem.get_attribute('id')) return fetch_bill(latest_bill_id, driver.get_cookies())
def fetch_portfolio_statement(driver: webdriver.remote.webdriver.WebDriver, creds: Credentials) -> bytes: """Fetches Degiro's portfolio statement using Selenium Returns: A CSV UTF-8 encoded statement. """ driver.implicitly_wait(30) login(creds, driver) wait_for_login(driver) return fetch_portfolio(driver)
def fetch_data(driver: webdriver.remote.webdriver.WebDriver, creds: Credentials) -> bytes: """Fetches Interactive Brokers's transaction data using Selenium Returns: A CSV with the fetched transactions. """ driver.implicitly_wait(60) login(creds, driver) wait_for_logged_in_state(driver) return fetch_account_statement(driver)
def fetch_account_history(driver: webdriver.remote.webdriver.WebDriver, creds: Credentials) -> bytes: """Fetches Charles Schwab's account history using Selenium Returns: A CSV UTF-8 encoded statement. """ driver.implicitly_wait(30) login(creds, driver) cookies = driver_cookie_jar_to_requests_cookies(driver.get_cookies()) return fetch_account_history_csv(cookies)
def fetch_data(creds: Credentials, gmail_creds: gmail.Credentials, driver: webdriver.remote.webdriver.WebDriver) -> bytes: """Fetches Finpensions' transaction data. Returns: A CSV UTF-8 encoded string with the fetched transactions. """ driver.implicitly_wait(30) login(creds, driver) wait_for_login(driver) time.sleep(2) mail_transactions(driver) return retry_n_times(lambda: fetch_csv_from_gmail(gmail_creds))
def login(creds: Credentials, driver: webdriver.remote.webdriver.WebDriver) -> None: driver.implicitly_wait(10) LOGIN_PAGE = 'https://app.revolut.com/start' driver.get(LOGIN_PAGE) form = driver.find_element(By.CSS_SELECTOR, 'form') country_code_input, phone_number_input = form.find_elements( By.CSS_SELECTOR, 'input') set_value(driver, country_code_input, creds.country_code) phone_number_input.send_keys(creds.phone_number + Keys.RETURN) fields = find_pin_input_fields(driver) fields[0].send_keys(creds.pin)