Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrisns/amazon-invoice-downloader
Automatically download Amazon Invoices as PDFs
https://github.com/chrisns/amazon-invoice-downloader
Last synced: about 1 month ago
JSON representation
Automatically download Amazon Invoices as PDFs
- Host: GitHub
- URL: https://github.com/chrisns/amazon-invoice-downloader
- Owner: chrisns
- License: mit
- Created: 2023-12-27T18:29:17.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-07-05T17:51:28.000Z (5 months ago)
- Last Synced: 2024-10-03T06:09:35.132Z (about 2 months ago)
- Language: Python
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
> Modified version to presume you've got chrome running already logged in to your amazon account with remote debug enabled at port `9223` and interested in `amazon.co.uk`
# Amazon Invoice Downloader
[![PyPI - Version](https://img.shields.io/pypi/v/amazon-invoice-downloader.svg)](https://pypi.org/project/amazon-invoice-downloader)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/amazon-invoice-downloader.svg)](https://pypi.org/project/amazon-invoice-downloader)-----
**Table of Contents**
- [Amazon Invoice Downloader](#amazon-invoice-downloader)
- [What it does](#what-it-does)
- [Usage](#usage)
- [License](#license)## What it does
This program `amazon-invoice-downloader.py` is a utility script that uses the [Playwright](https://playwright.dev/) library to spin up a Chromium instance and automate the process of downloading invoices for Amazon purchases within a specified date range. The script logs into Amazon using the provided email and password, navigates to the "Returns & Orders" section, and retrieves invoices for the specified year or date range.
The user can provide their Amazon login credentials either through command line arguments (--email= --password=) or as environment variables ($AMAZON_EMAIL and $AMAZON_PASSWORD).
The script accepts the date range either as a specific year (--year=) or as a date range (--date-range=). If no date range is provided, the script defaults to the current year.
Once the invoices are retrieved, they are saved as PDF files in a local "downloads" directory. The filename of each PDF is formatted as `YYYYMMDD__amazon_.pdf`, where YYYYMMDD is the date of the order, total is the total amount of the order (with dollar signs and commas removed), and orderid is the unique Amazon order ID.
The program has a built-in "human latency" function, sleep(), to mimic human behavior by introducing random pauses between certain actions. This can help prevent the script from being detected and blocked as a bot by Amazon.
The script will skip downloading a file if it already exists in the `./downloads` directory.
## Usage
```console
$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9223
$ hatch run pip install -e .
$ hatch run amazon-invoice-downloader --year 2023```console
$ amazon-invoice-downloader -h
Amazon Invoice DownloaderUsage:
amazon-invoice-downloader.py \
[--year= | --date-range=]
amazon-invoice-downloader.py (-h | --help)Date Range Options:
--date-range= Start and end date range
--year= Year, formatted as YYYY [default: ].Options:
-h --help Show this screen.Examples:
amazon-invoice-downloader.py --year=2022 # This uses env vars $AMAZON_EMAIL and $AMAZON_PASSWORD
amazon-invoice-downloader.py --date-range=20220101-20221231
amazon-invoice-downloader.py # Defaults to current year
amazon-invoice-downloader.py --year=2022
amazon-invoice-downloader.py --date-range=20220101-20221231
```## License
`amazon-invoice-downloader` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.