Coder Social home page Coder Social logo

cr7pt0gr4ph7 / amazon-invoice-downloader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dcwangmit01/amazon-invoice-downloader

0.0 0.0 0.0 19 KB

Automatically download Amazon Invoices as PDFs

License: MIT License

Python 81.16% Makefile 18.84%

amazon-invoice-downloader's Introduction

Amazon Invoice Downloader

PyPI - Version PyPI - Python Version


Table of Contents

What it does

This program amazon-invoice-downloader.py is a utility script that uses the Playwright 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_<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

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.

$ 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 protected] --password=secret  # Defaults to current year
  amazon-invoice-downloader.py [email protected] --password=secret --year=2022
  amazon-invoice-downloader.py [email protected] --password=secret --date-range=20220101-20221231

License

amazon-invoice-downloader is distributed under the terms of the MIT license.

amazon-invoice-downloader's People

Contributors

dcwangmit01 avatar cr7pt0gr4ph7 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.