Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

adapted to latest DKB UI. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions dkbweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _get_transaction_selection_form_ba(self):
"""
for form in self.br.forms():
try:
form.find_control(name="slAllAccounts")
form.find_control(name="slAllAccounts", type='select')
return form
except Exception:
continue
Expand Down Expand Up @@ -113,7 +113,7 @@ def _select_bank_account(self, form, baid):
transaction selection form.

@param mechanize.HTMLForm form
@param str baid: full bank account number
@param str baid: last 4 digits of IBAN
"""
try:
ba_list = form.find_control("slAllAccounts", type="select")
Expand All @@ -123,9 +123,11 @@ def _select_bank_account(self, form, baid):
for item in ba_list.get_items():
# find right bank account...
for label in item.get_labels():
bapattern = r'\b[A-Z]{2}\d{16}%s\b' % re.escape(baid)
# Trying to match lines that look like
# DE01 2345 6789 0123 4567 89 / GirokontoDE01 2345 6789 0123 4567 89 / Girokonto
bapattern = r'\b[A-Z]{2}[\d\s]{20}%s\s%s\b' % (re.escape(baid[:2]), re.escape(baid[2:]))
if re.search(bapattern, label.text, re.I):
form[ba_list.name] = [item.name]
form.value = [item.name]
return

raise RuntimeError("Unable to find the right bank account")
Expand All @@ -136,7 +138,7 @@ def select_transactions_ba(self, baid, from_date, to_date):
from_date and to_date for the bank account identified by the
given full bank account number.

@param str baid: full bank account number
@param str baid: last 4 digits of IBAN
@param str from_date dd.mm.YYYY
@param str to_date dd.mm.YYYY
"""
Expand Down Expand Up @@ -174,7 +176,7 @@ def logout(self):
cli.add_argument("--pin",
help="Your user PIN (same as used for login). Use with care!")
cli.add_argument("--baid",
help="Full bank account number")
help="Last 4 digits of your IBAN")
cli.add_argument("--cardid",
help="Last 4 digits of your card number")
cli.add_argument("--output", "-o",
Expand Down Expand Up @@ -278,7 +280,7 @@ def is_valid_date(date):

2. With dkbweb.py you can also query your bank account transactions:

./dkbweb.py --userid USER --baid 1234567890 --from-date 01.01.2015 --output ba.csv --raw
./dkbweb.py --userid USER --baid 1234 --from-date 01.01.2015 --output ba.csv --raw

3. With dkbweb.py you can also directly submit your PIN to the command line:

Expand Down
8 changes: 4 additions & 4 deletions test/test_baid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
import re

cardid = "0000"
label_text = "1234********0000 / Kreditkarte"
label_text = "1234********0000 / Kreditkarte1234********0000 / Kreditkarte"
ccpattern = r'\b\S{12}(?<=%s)\b' % re.escape(cardid)
ccpattern_all = r'\b\d{4}\S{12}(?<=%s)\b' % re.escape(cardid)

print(re.search(ccpattern, label_text, re.I).group(0))
print(re.search(ccpattern_all, label_text, re.I).group(0))

cardid = "0000"
label_text = "DE12345678901234560000 / Girokonto"
bapattern = r'\b[A-Z]{2}\d{16}%s\b' % re.escape(cardid)
baid = "0000"
label_text = "DE12 3456 7890 1234 5600 00 / GirokontoDE12 3456 7890 1234 5600 00 / Girokonto"
bapattern = r'\b[A-Z]{2}[\d\s]{20}%s\s%s\b' % (re.escape(baid[:2]), re.escape(baid[2:]))

print(re.search(bapattern, label_text, re.I).group(0))