download
- download(url: str, path: str | Path, *, force: bool = True, clean_on_failure: bool = True, backend: Literal['urllib', 'requests'] | None = None, hexdigests: Mapping[str, str] | None = None, hexdigests_remote: Mapping[str, str] | None = None, hexdigests_strict: bool = False, progress_bar: bool = True, tqdm_kwargs: Mapping[str, Any] | None = None, _version: str | None = None, **kwargs: Unpack[RequestKwargs]) None[source]
Download a file from a given URL.
- Parameters:
url – URL to download
path – Path to download the file to
force – If false and the file already exists, will not re-download.
clean_on_failure – If true, will delete the file on any exception raised during download
backend – The downloader to use. Choose ‘urllib’ or ‘requests’
hexdigests – The expected hexdigests as (algorithm_name, expected_hex_digest) pairs.
hexdigests_remote – The expected hexdigests as (algorithm_name, url to file with expected hexdigest) pairs.
hexdigests_strict – Set this to
Falseto stop automatically checking for the algorithm(filename)=hash formatprogress_bar – Set to true to show a progress bar while downloading
tqdm_kwargs – Override the default arguments passed to
tadm.tqdmwhen progress_bar is True.kwargs – If using
urllib.request.urlretrieve(), there are no keyword arguments available. If usingrequestsas a backend, passes these torequests.get(). If usingrequestsas a backend,streamis set to True by default.
- Raises:
Exception – Thrown if an error besides a keyboard interrupt is thrown during download
KeyboardInterrupt – If a keyboard interrupt is thrown during download
UnexpectedDirectory – If a directory is given for the
pathargumentValueError – If an invalid backend is chosen
DownloadError – If an error occurs during download