Skip to content
/ banes Public

A Python library for scraping Banorte transaction emails.

License

Notifications You must be signed in to change notification settings

ramomar/banes

Repository files navigation

banes

Build and test

banes (banorte email scraper) is a library for scraping transaction emails from Banorte.

Scrapers

The library includes scrapers of different types of emails collected over a two year period.

You can take a look here in order to see which emails have an scraper implemented already.

The parsing of the dates is up to you due to the weird formats Banorte uses. In my opinion those dates are not very accurate. I recommend taking a look at the timestamp of the email when it arrived in your inbox, and then comparing the two dates in order to see which one is better for your use case.

Usage

  1. Install the package.
pip install git+ssh://git@github.com/ramomar/banes.git
  1. Require the scraper and use it!
import base64
from banes import banorte_email

with open('email-in-b64') as email:
    html = base64.b64decode(email.read())

    print(banorte_email.scrape(html))

Example output

ExpenseRecord(
    source='FAST_TRANSFER_EMAIL',
    type='EXPENSE',
    note='Transferencias Rápidas | Pago de una cosa',
    operation_date='20/Jul/2020 22:14:36 horas',
    receiver=Receiver(
        name='Ana',
        bank='BANAMEX'
    ),
    amount='5.00',
    extra_amounts=[
        ExtraAmount(
            name='fee',
            amount='3.00',
            tax='0.48'
        )
    ]
)

You can also independently import the scrapers listed here.

Record types

Record type Description
INCOME A record that represents an income.
EXPENSE A record that represents an expense.
ACCOUNT_OPERATION A record that represents an account operation log (change of NIP, virtual card limit modification, etc).

You can get more details on the structure of the records here.

Development

Testing

In order to run tests you might do pytest.

Type checking

In order to run type checking you might do mypy banes.