is_downloadable

pyhelpers.ops.is_downloadable(url, request_field='content-type', **kwargs)[source]

Check whether a URL leads to a web page where there is downloadable contents.

Parameters:
  • url (str) – a valid URL

  • request_field (str) – name of the field/header indicating the original media type of the resource, defaults to 'content-type'

  • kwargs – [optional] parameters of requests.head

Returns:

whether the url leads to downloadable contents

Return type:

bool

Examples:

>>> from pyhelpers.ops import is_downloadable

>>> logo_url = 'https://www.python.org/static/community_logos/python-logo-master-v3-TM.png'
>>> is_downloadable(logo_url)
True

>>> google_url = 'https://www.google.co.uk/'
>>> is_downloadable(google_url)
False