# 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**
- [Installation](#installation)
- [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=<email> --password=<password>) or as environment variables ($AMAZON_EMAIL and $AMAZON_PASSWORD).
The script accepts the date range either as a specific year (--year=<YYYY>) or as a date range (--date-range=<YYYYMMDD-YYYYMMDD>). 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_<total>_amazon_<orderid>.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.
## Installation
```console
pip install amazon-invoice-downloader
playwright install
```
## Usage
When running this program, Amazon may detect you are automation and introduce CAPTCHA's or make you login again. Just do so, and once successfully logged in, the script will continue.
```console
$ amazon-invoice-downloader -h
Amazon Invoice Downloader
Usage:
amazon-invoice-downloader.py \
[--email=<email> --password=<password>] \
[--year=<YYYY> | --date-range=<YYYYMMDD-YYYYMMDD>]
amazon-invoice-downloader.py (-h | --help)
Login Options:
--email=<email> Amazon login email [default: $AMAZON_EMAIL].
--password=<password> Amazon login password [default: $AMAZON_PASSWORD].
Date Range Options:
--date-range=<YYYYMMDD-YYYYMMDD> Start and end date range
--year=<YYYY> Year, formatted as YYYY [default: <CUR_YEAR>].
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 --email=user@example.com --password=secret # Defaults to current year
amazon-invoice-downloader.py --email=user@example.com --password=secret --year=2022
amazon-invoice-downloader.py --email=user@example.com --password=secret --date-range=20220101-20221231
```
## License
`amazon-invoice-downloader` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
Raw data
{
"_id": null,
"home_page": null,
"name": "amazon-invoice-downloader",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "amazon,download,invoice,pdf,statements",
"author": null,
"author_email": "David C Wang <dcwangmit01@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/b5/12/16ba49ef812c763429df4d0b6dcea4a62fc1bba3c7ca025e516fa053363d/amazon_invoice_downloader-0.4.0.tar.gz",
"platform": null,
"description": "# Amazon Invoice Downloader\n\n[![PyPI - Version](https://img.shields.io/pypi/v/amazon-invoice-downloader.svg)](https://pypi.org/project/amazon-invoice-downloader)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/amazon-invoice-downloader.svg)](https://pypi.org/project/amazon-invoice-downloader)\n\n-----\n\n**Table of Contents**\n\n- [Installation](#installation)\n- [License](#license)\n\n## What it does\n\n\nThis 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.\n\nThe user can provide their Amazon login credentials either through command line arguments (--email=<email> --password=<password>) or as environment variables ($AMAZON_EMAIL and $AMAZON_PASSWORD).\n\nThe script accepts the date range either as a specific year (--year=<YYYY>) or as a date range (--date-range=<YYYYMMDD-YYYYMMDD>). If no date range is provided, the script defaults to the current year.\n\nOnce the invoices are retrieved, they are saved as PDF files in a local \"downloads\" directory. The filename of each PDF is formatted as `YYYYMMDD_<total>_amazon_<orderid>.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.\n\nThe 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.\n\nThe script will skip downloading a file if it already exists in the `./downloads` directory.\n\n## Installation\n\n```console\npip install amazon-invoice-downloader\nplaywright install\n```\n\n## Usage\n\nWhen running this program, Amazon may detect you are automation and introduce CAPTCHA's or make you login again. Just do so, and once successfully logged in, the script will continue.\n\n```console\n$ amazon-invoice-downloader -h\nAmazon Invoice Downloader\n\nUsage:\n amazon-invoice-downloader.py \\\n [--email=<email> --password=<password>] \\\n [--year=<YYYY> | --date-range=<YYYYMMDD-YYYYMMDD>]\n amazon-invoice-downloader.py (-h | --help)\n\nLogin Options:\n --email=<email> Amazon login email [default: $AMAZON_EMAIL].\n --password=<password> Amazon login password [default: $AMAZON_PASSWORD].\n\nDate Range Options:\n --date-range=<YYYYMMDD-YYYYMMDD> Start and end date range\n --year=<YYYY> Year, formatted as YYYY [default: <CUR_YEAR>].\n\nOptions:\n -h --help Show this screen.\n\nExamples:\n amazon-invoice-downloader.py --year=2022 # This uses env vars $AMAZON_EMAIL and $AMAZON_PASSWORD\n amazon-invoice-downloader.py --date-range=20220101-20221231\n amazon-invoice-downloader.py --email=user@example.com --password=secret # Defaults to current year\n amazon-invoice-downloader.py --email=user@example.com --password=secret --year=2022\n amazon-invoice-downloader.py --email=user@example.com --password=secret --date-range=20220101-20221231\n```\n\n\n## License\n\n`amazon-invoice-downloader` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n",
"bugtrack_url": null,
"license": null,
"summary": "Logs into an Amazon.com account and downloads invoices as PDF",
"version": "0.4.0",
"project_urls": {
"Documentation": "https://github.com/dcwangmit01/amazon-invoice-downloader#readme",
"Issues": "https://github.com/dcwangmit01/amazon-invoice-downloader/issues",
"Source": "https://github.com/dcwangmit01/amazon-invoice-downloader"
},
"split_keywords": [
"amazon",
"download",
"invoice",
"pdf",
"statements"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ac3d42b13e734ddba89d2557a314067ecbde425408b53aa8ab4010031e60508a",
"md5": "8d13b81831d82d86242be0cb5eaa1869",
"sha256": "bdd5bdb372709eaa49d4e89cd489a7cce8fbdd25a2d2091cf29e21cd258c3f31"
},
"downloads": -1,
"filename": "amazon_invoice_downloader-0.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8d13b81831d82d86242be0cb5eaa1869",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7241,
"upload_time": "2024-02-06T22:33:30",
"upload_time_iso_8601": "2024-02-06T22:33:30.481096Z",
"url": "https://files.pythonhosted.org/packages/ac/3d/42b13e734ddba89d2557a314067ecbde425408b53aa8ab4010031e60508a/amazon_invoice_downloader-0.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "b51216ba49ef812c763429df4d0b6dcea4a62fc1bba3c7ca025e516fa053363d",
"md5": "31dca01e0c4a436384a95d7b678d6b5a",
"sha256": "1c536f511ca44b51c1f41e68a105618e13c44afe4edbf277c0878a66583c668d"
},
"downloads": -1,
"filename": "amazon_invoice_downloader-0.4.0.tar.gz",
"has_sig": false,
"md5_digest": "31dca01e0c4a436384a95d7b678d6b5a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 10074095,
"upload_time": "2024-02-06T22:33:28",
"upload_time_iso_8601": "2024-02-06T22:33:28.018255Z",
"url": "https://files.pythonhosted.org/packages/b5/12/16ba49ef812c763429df4d0b6dcea4a62fc1bba3c7ca025e516fa053363d/amazon_invoice_downloader-0.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-06 22:33:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dcwangmit01",
"github_project": "amazon-invoice-downloader#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "amazon-invoice-downloader"
}