Skip to main content

Tools for scraping personal financial data.

Project description

Python package for scraping personal financial data from financial institutions.

License: GPL v2 PyPI Build

This package may be useful on its own, but is specifically designed to be used with beancount-import.

Supported data sources

Setup

To install the most recent published package from PyPi, simply type:

pip install finance-dl

To install from a clone of the repository, type:

pip install .

or for development:

pip install -e .

Configuration

Create a configuration file called something like finance_dl_config.py. For a complete example of this file and some documentation, see example_finance_dl_config.py.

Refer to the documentation of the individual scraper modules for further details.

Basic Usage

You can run a scraping configuration named myconfig as follows:

python -m finance_dl.cli --config-module example_finance_dl_config --config myconfig

The configuration myconfig refers to a function named CONFIG_myconfig in the configuration module.

Make sure that your configuration module is accessible in your Python sys.path. Since sys.path includes the current directory by default, you can simply run this command from the directory that contains your configuration module.

By default, the scrapers run fully automatically, and the ones based on selenium and chromedriver run in headless mode. If the initial attempt for a selenium-based scraper fails, it is automatically retried again with the browser window visible. This allows you to manually complete the login process and enter any multi-factor authentication code that is required.

To debug a scraper, you can run it in interactive mode by specifying the -i command-line argument. This runs an interactive IPython shell that lets you manually invoke parts of the scraping process.

Automatic Usage

To run multiple configurations at once, and keep track of when each configuration was last updated, you can use the finance_dl.update tool.

To display the update status, first create a logs directory and run:

python -m finance_dl.update --config-module example_finance_dl_config --log-dir logs status

Initially, this will indicate that none of the configurations have been updated. To update a single configuration myconfig, run:

python -m finance_dl.update --config-module example_finance_dl_config --log-dir logs update myconfig

With a single configuration specified, this does the same thing as the finance_dl.cli tool, except that the log messages are written to logs/myconfig.txt and a logs/myconfig.lastupdate file is created if it is successful.

If multiple configurations are specified, as in:

python -m finance_dl.update --config-module example_finance_dl_config --log-dir logs update myconfig1 myconfig2

then all specified configurations are run in parallel.

To update all configurations, run:

python -m finance_dl.update --config-module example_finance_dl_config --log-dir logs update --all

Note on Chromedriver Versioning

Chromedriver and Chrome are very tightly coupled; their versions need to match. finance_dl uses Chromedriver from the chromedriver_binary Python package (not your system's installed Chromedriver binary). However, Chromedriver, by default, uses your system's installed version of Chrome. Depending on how you manage the two installations on your system, this combination may frequently end up causing finance_dl to fail with messages like

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 97
Current browser version is 96.0.4664.45 with binary path /usr/bin/google-chrome

In this event, you have a few options:

  1. Explicitly manage your version of the chromedriver_binary Python package to match your installed version of Chrome;
  2. Explicitly manage your installed version of Chrome to match your version of the chromedriver_binary Python package; or
  3. Install the version of Chrome matching your version of chromedriver_binary somewhere other than your system's default Chrome version, and set the environment variable CHROMEDRIVER_CHROME_BINARY to point to it. (You can do this from within your finance_dl config script, e.g. with a line like os.environ["CHROMEDRIVER_CHROME_BINARY"] = "/usr/bin/google-chrome-beta").

License

Copyright (C) 2014-2018 Jeremy Maitin-Shepard.

Distributed under the GNU General Public License, Version 2.0 only. See LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

finance_dl-1.3.4-py3-none-any.whl (88.8 kB view details)

Uploaded Python 3

File details

Details for the file finance_dl-1.3.4-py3-none-any.whl.

File metadata

  • Download URL: finance_dl-1.3.4-py3-none-any.whl
  • Upload date:
  • Size: 88.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.19

File hashes

Hashes for finance_dl-1.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1379a49eafd5c8b1b261e3e04eee9868ec9916e4d635a794cfa8e49cf0d651ee
MD5 56a579f576a55a1bc9951ff9e00ecfb6
BLAKE2b-256 f98e29e00ff4f4d68f1fba21d3cca98788e9a33703e159817d8946798c605c02

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page