requests_downloader package

Submodules

requests_downloader.cli module

Command Line Interface for requests_downloader

requests_downloader.cli.main()[source]

CLI for requests_downloader

requests_downloader.downloader module

Main module containing download function

requests_downloader.downloader.download(url, download_dir='', download_file=None, download_path=None, headers={}, session=None, block_size=1024, timeout=60, resume=True, show_progress=True, show_progress_desc=True, max_desc_length=35, checksum=None, smart=True, url_handler=None)[source]

Download a file

Parameters:
  • url (str) – URL to download.
  • download_dir (str, optional) – Path of the directory to download the file in. The default is ‘’ (i.e. current directory).
  • download_file (str, optional) – Name for the downloaded file. If None, the function will infer it from URL and Content-Disposition The default is None.
  • download_path (str, optional) – Full path where the downloaded file should be saved. If None, the function will save it in download_dir/download_file If provided, download_dir and download_file arguments are ignored. The default is None.
  • headers (dict, optional) –

    Headers to be sent. The default is {}. Note:

    • These headers are merged with a default set of headers.
    • In case of a conflict the user-provided values are used.
    • This behaviour is inherited from requests.Session()
  • session (object, optional) – A valid requests.Session object. This is useful when download url requires authentication. In such a case, authentication can be handled independently in session. The default is None.
  • block_size (int, optional) – Block size, in bytes, to stream the downloadable content. The default is 1024.
  • timeout (float, optional) – Timeout, in seconds The default is 60.
  • resume (bool, optional) – Try to resume download. The default is True.
  • show_progress (bool, optional) – Show progressbar. The default is True.
  • show_progress_desc (str or bool, optional) – Show the description to the left of progressbar. If False or None, no description is shown. If True, the name of file being downloaded is shown. Otherwise, the str() of the provided value is shown. The default is True.
  • max_desc_length (int, optional) – If length of the description is more, abbreviate it by showing the first and last parts connected by three dots. The default is 35.
  • checksum (str, optional) – Value of md5 checksum of the file to be downloaded. If provided, the downloaded file will be verified using the checksum. The default is None.
  • smart (bool, optional) – Use url_handler for special case URLs The default is True.
  • url_handler (function, optional) – Handler function for special cases of download URLs The function should return a list of (TAG, URL) pairs and default index
Returns:

download_path – If download was successful, full download_path otherwise, None

Return type:

str or None

Module contents

requests_downloader

Python package to download files