Skip to content

Instantly share code, notes, and snippets.

@tofran
Last active April 1, 2024 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tofran/345edcf522685ef26408371b18763662 to your computer and use it in GitHub Desktop.
Save tofran/345edcf522685ef26408371b18763662 to your computer and use it in GitHub Desktop.
Bolt business invoice downloader

Bolt business invoice downloader

Quick and dirty script to download Bolt invoices.

Use it as you wish, might be usefull for someone.

Usage

First you need a .csv statement. Go to https://business.bolt.eu/ then > Billing > Statements > Choose a month and download the "Rides" statement as .csv.

  • Optional - consider crating a virtualenv (python3 -m venv venv and source ./venv/bin/activate)
  • Install deps: pip install -r requirements
  • Download invoice by running python Download_invoices.py. It will prompt you for the .csv path.

License

MIT

import csv
import requests
from datetime import datetime
def download_and_save_invoice(url, date_str):
response = requests.get(url)
response.raise_for_status()
file_name = f"ride_{date_str}.pdf"
with open(file_name, 'wb') as file:
file.write(response.content)
print(f"Downloaded and saved invoice: {file_name}")
def download_invoices(csv_file_path):
print(f"Downloading {csv_file_path}")
with open(
csv_file_path,
mode='r',
encoding='utf-8-sig',
) as csv_file:
csv_reader = csv.DictReader(csv_file)
for row in csv_reader:
invoice_url = row.get("Invoice")
date_str = row.get("Date")
if invoice_url is None or date_str is None:
raise RuntimeError("Missing invoice_url or date_str")
date_obj = datetime.strptime(date_str, "%Y-%m-%d %H:%M:%S")
formatted_date = date_obj.strftime("%Y-%m-%d_%H-%M-%S")
download_and_save_invoice(invoice_url, formatted_date)
if __name__ == "__main__":
csv_file_path = input("file path:")
download_invoices(csv_file_path)
requests==2.31.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment