Skip to content

Instantly share code, notes, and snippets.

@hasandiwan
Last active January 5, 2021 08:46
Show Gist options
  • Save hasandiwan/5bd0849d8d5fb0ec98c8883a5889f5a2 to your computer and use it in GitHub Desktop.
Save hasandiwan/5bd0849d8d5fb0ec98c8883a5889f5a2 to your computer and use it in GitHub Desktop.
Gets your balance from mint.com

The above script marches onto mint.com logs the user in with their password and reports the user's cash balance. You'll need chromedriver for the appropriate version of Chrome -- it has been tested with version 87. However, it should work with all other versions, provided the webdriver version matches.

import argparse
import sys
import selenium.webdriver as webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
BALANCE_SELECTOR = '''#moduleAccounts-bank > div > h3 > span.balance'''
def main():
parser = argparse.ArgumentParser(description='Get mint.com balance')
parser.add_argument('--username', type=str, action='store', help='Your mint.com username')
parser.add_argument('--password', type=str, action='store', help='Your mint.com password')
args = parser.parse_args()
if not args.username or not args.password:
parser.print_help()
sys.exit(2)
try:
with webdriver.Chrome() as driver:
driver.get("https://mint.com")
driver.find_element(By.CSS_SELECTOR, 'body > div.cgmt-bgcolor-white > div > header > div.container-cms--header > div.gqvk__header.component-margin > div > div.gqvk__buttons.btn-inline-container.btn-small-container.show-all-buttons > a.btn.btn-secondary.beacon-this').click()
element = driver.find_element(By.CSS_SELECTOR, '#ius-userid')
element.send_keys(args.username)
elem = driver.find_element(By.CSS_SELECTOR, '#ius-password')
elem.send_keys(args.password)
elem.submit()
wait = WebDriverWait(driver, 90)
ec = EC.visibility_of_element_located((By.CSS_SELECTOR, BALANCE_SELECTOR))
wait.until(ec)
element = driver.find_element(By.CSS_SELECTOR, BALANCE_SELECTOR)
print(f"Your balance is {element.text}")
except Exception as s:
print(str(s))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment