-
Notifications
You must be signed in to change notification settings - Fork 1
/
banco_do_brasil_navigator.py
80 lines (56 loc) · 2.13 KB
/
banco_do_brasil_navigator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
__author__ = 'igor.sa'
from selenium import webdriver
import time
from appscript import app, k
import osutils
class Navigator:
MONTH_JAN = "JAN"
MONTH_FEB = "FEV"
MONTH_MAR = "MAR"
MONTH_APR = "ABR"
MONTH_MAY = "MAI"
MONTH_JUN = "JUN"
MONTH_JUL = "JUL"
MONTH_AUG = "AGO"
MONTH_SEP = "SET"
MONTH_OCT = "OUT"
MONTH_NOV = "NOV"
MONTH_DEC = "DEZ"
def __init__(self):
self.browser = webdriver.Firefox()
self.browser.get("https://www2.bancobrasil.com.br/aapf/login.jsp")
time.sleep(20)
def execute_login(self, branch, account, password):
elem = self.browser.find_element_by_name("dependenciaOrigem")
elem.send_keys(branch)
elem = self.browser.find_element_by_name("numeroContratoOrigem")
elem.send_keys(account)
elem = self.browser.find_element_by_name("senhaConta")
elem.send_keys(password)
elem = self.browser.find_element_by_name("botaoEntrar.x")
elem.click()
time.sleep(5)
def export_transactions(self, default_download_dir_path, from_day = None, month = None):
self.browser.get("https://www2.bancobrasil.com.br/aapf/extrato/009-00.jsp?ac=sim&disponivelSMS=sim&codigoImagem=27919#ancoraTitulo")
time.sleep(5)
if from_day == None:
from_day = "%d" % from_day
elem = self.browser.find_element_by_name("dia")
elem.send_keys(from_day)
elem = self.browser.find_element_by_xpath('//input[@name="tipoExtrato"][@value="2"]')
elem.click()
if month != None:
elem = self.browser.find_element_by_name("mes")
elem.click()
app('Firefox').activate()
app('System Events').keystroke(month)
app('Firefox').activate()
app('System Events').keystroke('\r')
elem = self.browser.find_element_by_name("botaoConfirma.x")
elem.click()
time.sleep(20)
app('Firefox').activate()
app('System Events').keystroke('\r')
return osutils.get_last_created_file(default_download_dir_path, ".ofx")
def close(self):
self.browser.close()