123 lines
3.5 KiB
Markdown
123 lines
3.5 KiB
Markdown
# Amazon Invoice Downloader
|
|
|
|
Ladet Amazon-Rechnungen fuer einen konfigurierbaren Zeitraum herunter.
|
|
|
|
## Voraussetzungen
|
|
|
|
- Windows/macOS/Linux
|
|
- Python 3.10+
|
|
- Ein Amazon-Konto
|
|
|
|
## Installation
|
|
|
|
```powershell
|
|
cd c:\projekte\amazon_invoice_downloader
|
|
python -m venv .venv
|
|
.\.venv\Scripts\Activate.ps1
|
|
pip install -r requirements.txt
|
|
python -m playwright install chromium
|
|
```
|
|
|
|
## Einmalige Konfiguration
|
|
|
|
```powershell
|
|
python main.py configure --marketplace de --download-dir "C:\Users\<USER>\Downloads\amazon_rechnungen"
|
|
```
|
|
|
|
Dann oeffnet sich ein Browser. Dort bei Amazon anmelden und auf Enter im Terminal druecken.
|
|
Die Session wird lokal gespeichert in:
|
|
|
|
- `~/.amazon_invoice_downloader/config.json`
|
|
- `~/.amazon_invoice_downloader/storage_state.json`
|
|
|
|
## Rechnungen herunterladen
|
|
|
|
```powershell
|
|
python main.py download --from 2025-01-01 --to 2025-12-31
|
|
```
|
|
|
|
## Docker Compose
|
|
|
|
Container-Image bauen:
|
|
|
|
```powershell
|
|
cd c:\projekte\amazon_invoice_downloader
|
|
docker compose build
|
|
```
|
|
|
|
Session direkt im Container erzeugen (Ubuntu mit Desktop/X11):
|
|
|
|
```bash
|
|
sudo apt-get update && sudo apt-get install -y x11-xserver-utils
|
|
xhost +local:docker
|
|
docker compose --profile configure run --rm amazon-invoice-configure
|
|
xhost -local:docker
|
|
```
|
|
|
|
Im geöffneten Browser bei Amazon anmelden und danach im Terminal `Enter` drücken.
|
|
Die Session liegt anschließend in `./state/storage_state.json`.
|
|
|
|
Session auf Ubuntu Server ohne GUI (noVNC):
|
|
|
|
```bash
|
|
docker compose --profile configure-novnc build --no-cache amazon-invoice-configure-novnc
|
|
docker compose --profile configure-novnc up amazon-invoice-configure-novnc
|
|
```
|
|
|
|
Dann im Browser auf deinem PC oeffnen:
|
|
|
|
```text
|
|
http://<SERVER-IP>:6080/vnc.html
|
|
```
|
|
|
|
Im noVNC-Fenster bei Amazon einloggen. Die Session wird nach `LOGIN_WAIT_SECONDS` (Standard: 300s) automatisch gespeichert.
|
|
Anschließend kannst du den noVNC-Container beenden (`Ctrl+C` im Terminal).
|
|
|
|
Alternative per Hilfsskript:
|
|
|
|
```bash
|
|
chmod +x ./startConfigure.sh
|
|
./startConfigure.sh
|
|
```
|
|
|
|
Rechnungen im Container herunterladen:
|
|
|
|
```powershell
|
|
docker compose run --rm amazon-invoice-downloader download --from 2025-01-01 --to 2025-12-31 --headless true
|
|
```
|
|
|
|
Alternative per Hilfsskript:
|
|
|
|
```bash
|
|
chmod +x ./startDownload.sh
|
|
./startDownload.sh 2025-01-01 2025-12-31
|
|
```
|
|
|
|
Persistente Ordner:
|
|
|
|
- `./state` -> `/root/.amazon_invoice_downloader` (config + session)
|
|
- `./downloads` -> `/downloads` (Ausgabedateien)
|
|
|
|
Falls noch nicht vorhanden, werden `config.json` und `storage_state.json` beim `configure`-Lauf in `./state` angelegt.
|
|
|
|
Optionaler Zielordner im Container:
|
|
|
|
```powershell
|
|
docker compose run --rm amazon-invoice-downloader download --from 2025-01-01 --to 2025-12-31 --output /downloads --headless true
|
|
```
|
|
|
|
Optionen:
|
|
|
|
- `--output <pfad>`: anderes Zielverzeichnis
|
|
- `--max-pages 25`: Anzahl Bestellseiten, die durchsucht werden
|
|
- `--headless true|false`: Browser sichtbar oder unsichtbar
|
|
- `--debug`: zeigt, wie viele Detailseiten und Rechnungslinks gefunden werden
|
|
- `--debug-json [pfad]`: schreibt Laufdetails als JSON (ohne Pfad: Standarddatei)
|
|
|
|
## Hinweise
|
|
|
|
- Das Skript setzt pro Jahr den Amazon-Filter `timeFilter=year-YYYY` auf `your-orders/orders`, damit Zeitraeume wie Januar 2025 korrekt durchlaufen werden.
|
|
- Die Datumspruefung erfolgt direkt auf der Uebersichtsseite in den `order-card`-Elementen; Detailseiten sind nicht mehr der Primaerpfad.
|
|
- Amazon-HTML kann sich aendern. Falls keine Rechnungen gefunden werden, `--debug --debug-json` nutzen.
|
|
- Der Login ist absichtlich sessionbasiert statt Passwortspeicherung.
|
|
- Bitte nur gemaess Amazon-AGB nutzen.
|