HathiTrust Downloader
Installing
Python 3 (OS Agnostic)
Check that you have Python 3 installed and available on your shell. The following command should return something like Python 3.12.5.
python -V
Windows users: Make sure to enable the "Add to PATH" option when installing Python.
Now you can install using pip with the following command.
pip install hathitrust-downloader
Which allows you to interact with the downloader from the command line:
hathitrust-downloader --help
Windows Executable
There are also Windows executables available. Download the downloader_<version>_win.zip from releases and extract it. Then open a shell, e.g. cmd or powershell, to the directory where the ZIP is extracted. The easiest way to do this is by opening the folder in Explorer and right click while holding shift, now select the option "Open PowerShell Window Here".
The executable is bundled with Python and all other dependencies, hence you do not need to have anything installed. Now the tool can be used like:
.\downloader.exe --help
Usage
The help should give some instructions on how to use the tool:
usage: hathitrust-downloader [-h] [--name NAME] [--user-agent USER_AGENT] [--max-retries MAX_RETRIES] id start_page end_page
Book downloader for HathiTrust
positional arguments:
id The ID of the book, e.g 'mdp.39015002388380' or a complete URL.
start_page The page number of the first page to be downloaded.
end_page The last number of the last page to be downloaded (inclusive).
options:
-h, --help show this help message and exit
--name NAME The start of the filename. Defaults to using the id. This can also be used to change the path.
--user-agent USER_AGENT
The User-Agent string to use for requests.
--max-retries MAX_RETRIES
The maximum number of retries for retriable errors (e.g., 403 Forbidden) before skipping a page. Default is 8.
For example, the following command will download page 1 until (and including) 10 of the book with id mdp.39015073487137 and naming the files output files my-book_page_<page_number>.pdf:
hathitrust-downloader mdp.39015073487137 1 10 --name my-book
Troubleshooting
No Progess / Progress Bar is Stuck
Make sure that you can access books on HathiTrust. Try to open a book in your browser to see if everything is working fine. HathiTrust can require you to connect from an American IP. In addition, they limit the amount of pages you can download to 15 every 5 minutes. When you hit that limit you will need to wait, the tool will automatically wait and resume when the timeout is finished.
Developing
Clone the repository:
git clone https://github.com/Addono/HathiTrust-downloader.git
cd ./HathiTrust-downloader
(Optional) Create a virtual Python environment, recommended but not required.
Install the package with dependencies:
pip install .
Now you can run the tool with:
python -m hathitrustdownloader.cli --help
Release files for hathitrust-downloader 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hathitrust_downloader-1.4.0.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hathitrust_downloader-1.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.6 kB
Release files / hathitrust_downloader-1.4.0.tar.gz
| Download URL | hathitrust_downloader-1.4.0.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
efb2b40ee07075b171c0407fcefb07200ef99522de57ef5ed71e18caeaecfe2b
|
|
BLAKE2b-256 checksum How to use checksums |
527384cd4881245bb5dfe38e81a6c99565477e3809509d0177f3c755bba8f767
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.17
|
Release files / hathitrust_downloader-1.4.0-py3-none-any.whl
| Download URL | hathitrust_downloader-1.4.0-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
57ec0b1625db9c07feb0fa46baa53c64484471c8ea328b755564d77a41033450
|
|
BLAKE2b-256 checksum How to use checksums |
9d258164e284c7e1d6717de4f5140fdf8516d5cbce6774f413bf826f51dd1a28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.17
|