Skip to main content

Download a book as PDF from https://www.hanser-elibrary.com/

Project description

hanser-py-library

This tool downloads a book from https://www.hanser-elibrary.com saves them to a PDF File called -.pdf. If the book's title contains characters that aren't allowed in a filename it will be saved as -.pdf. If files with that name already exist the number of existing files will be appended to the chosen file name like this (#).

By default the merged book will be saved in the directory from which the program was called, but you can provide a custom output directory.

If a complete book pdf is available, the tool will preferably download that file, otherwise it will download each individual chapter and merge them into a single file before saving. Unfortunately, this leads to links within the merged book (e.g. chapter references) being broken.

The tool will check whether you are authorized to access the book before downloading anything. If you are unauthorized, the book will be skipped.

Installation

Installing through pipx isolates packages in their own environment and exposes their entrypoints via PATH.

pipx install hanser-py-library

Alternatively install regularly via pip:

pip install hanser-py-library

Usage

usage: hanser [-h] [--isbn [[...]]] [-o PATH] [-f] [URL [URL ...]]

You must provide at least one valid URL or ISBN. The program will attempt to fix URLs with missing schemes by defaulting to "https://". Each URL needs to end with a valid ISBN-10 or -13 number. Valid URL formats include:

Referencing by ISBN-10 or ISBN-13

https://www.hanser-elibrary.com/isbn/{ISBN}
https://hanser-elibrary.com/isbn/{ISBN}
www.hanser-elibrary.com/isbn/{ISBN}
hanser-elibrary.com/isbn/{ISBN}

Referencing by DOI and ISBN-13

https://www.hanser-elibrary.com/doi/book/{DOI}/{ISBN}
https://hanser-elibrary.com/doi/book/{DOI}/{ISBN}
www.hanser-elibrary.com/doi/book/{DOI}/{ISBN}
hanser-elibrary.com/doi/book/{DOI}/{ISBN}

Options

Short Long Description
-h --help Show help message and exit.
-o --out Path to output directory. Relative and abstract paths supported. Cannot point towards file.
Paths starting with '~' it will be expanded from the user's home directory
Path must point towards existing directory unless -f is set.
-f --force If set the output directory and every directory on the way will be forcibly created.
Exits if the directory cannot be created.
--isbn ISBNs of books to download. Can be either ISBN-10 or 13.
If you want to provide both ISBNs and URLs, provide URLs first like this:
hanser [URL [URL ...]] [--isbn [[...]]]
If ISBN(s) and URL(s) are provided, URL books will be downloaded before ISBN books.

Examples

Saving in current working directory

hanser https://www.hanser-elibrary.com/isbn/9783446450776

hanser https://www.hanser-elibrary.com/doi/book/10.3139/9783446450776

hanser --isbn 9783446450776

Saving in a directory that exists

hanser -o path/to/dir hanser-elibrary.com/isbn/9783446450776

Saving in a directory that may or may not exist

hanser -o path/to/dir -f hanser-elibrary.com/isbn/9783446450523

Encountered a Bug?

Feel free to open an issue if you encountered bugs or have other ideas that aren't yet listed in the backlog.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hanser-py-library-0.3.4.tar.gz (24.7 kB view details)

Uploaded Source

File details

Details for the file hanser-py-library-0.3.4.tar.gz.

File metadata

  • Download URL: hanser-py-library-0.3.4.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for hanser-py-library-0.3.4.tar.gz
Algorithm Hash digest
SHA256 c304bb1540044839f8472f90f4d16a3d949c2dae846149a300f1c1b3e4c772fa
MD5 b833d577bd36adb77989930fa3e76d28
BLAKE2b-256 b36f426324170398c3a209d9b583f936f3e4bef6cf2c3f04f386d58bbb9f94b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page