requests_download


Namerequests_download JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://www.github.com/takluyver/requests_download
SummaryDownload files using requests and save them to a target path
upload_time2017-12-13 21:45:16
maintainer
docs_urlNone
authorThomas Kluyver
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            A convenient function to download to a file using requests.

Basic usage:

.. code-block:: python

    url = "https://github.com/takluyver/requests_download/archive/master.zip"
    download(url, "requests_download.zip")

An optional ``headers=`` parameter is passed through to requests.

**Trackers** are a lightweight way to monitor the data being downloaded.
Two trackers are included:

- ``ProgressTracker`` - displays a progress bar, using the `progressbar2
  <https://pypi.python.org/pypi/progressbar2>`_ package.
- ``HashTracker`` - wraps a hashlib object to calculate a hash (e.g. sha256 or
  md5) of the file as you download it.

Here's an example of using both of them:

.. code-block:: python

    import hashlib
    # progressbar is provided by progressbar2 on PYPI.
    from progressbar import DataTransferBar
    from requests_download import download, HashTracker, ProgressTracker

    hasher = HashTracker(hashlib.sha256())
    progress = ProgressTracker(DataTransferBar())

    download('https://github.com/takluyver/requests_download/archive/master.zip',
             'requests_download.zip', trackers=(hasher, progress))

    assert hasher.hashobj.hexdigest() == '...'

To make your own tracker, subclass TrackerBase and define any of these methods:

.. code-block:: python

    from requests_download import TrackerBase

    class MyTracker(TrackerBase):
        def on_start(self, response):
            """Called with requests.Response object, which has response headers"""
            pass

        def on_chunk(self, chunk):
            """Called multiple times, with bytestrings of data received"""
            pass

        def on_finish(self):
            """Called when the download has completed"""
            pass

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.github.com/takluyver/requests_download",
    "name": "requests_download",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Thomas Kluyver",
    "author_email": "thomas@kluyver.me.uk",
    "download_url": "https://files.pythonhosted.org/packages/34/9d/431a25538f158a3065a76a6311f40b7908f88a4d24efdbb0ca24f83bd614/requests_download-0.1.2.tar.gz",
    "platform": "",
    "description": "A convenient function to download to a file using requests.\n\nBasic usage:\n\n.. code-block:: python\n\n    url = \"https://github.com/takluyver/requests_download/archive/master.zip\"\n    download(url, \"requests_download.zip\")\n\nAn optional ``headers=`` parameter is passed through to requests.\n\n**Trackers** are a lightweight way to monitor the data being downloaded.\nTwo trackers are included:\n\n- ``ProgressTracker`` - displays a progress bar, using the `progressbar2\n  <https://pypi.python.org/pypi/progressbar2>`_ package.\n- ``HashTracker`` - wraps a hashlib object to calculate a hash (e.g. sha256 or\n  md5) of the file as you download it.\n\nHere's an example of using both of them:\n\n.. code-block:: python\n\n    import hashlib\n    # progressbar is provided by progressbar2 on PYPI.\n    from progressbar import DataTransferBar\n    from requests_download import download, HashTracker, ProgressTracker\n\n    hasher = HashTracker(hashlib.sha256())\n    progress = ProgressTracker(DataTransferBar())\n\n    download('https://github.com/takluyver/requests_download/archive/master.zip',\n             'requests_download.zip', trackers=(hasher, progress))\n\n    assert hasher.hashobj.hexdigest() == '...'\n\nTo make your own tracker, subclass TrackerBase and define any of these methods:\n\n.. code-block:: python\n\n    from requests_download import TrackerBase\n\n    class MyTracker(TrackerBase):\n        def on_start(self, response):\n            \"\"\"Called with requests.Response object, which has response headers\"\"\"\n            pass\n\n        def on_chunk(self, chunk):\n            \"\"\"Called multiple times, with bytestrings of data received\"\"\"\n            pass\n\n        def on_finish(self):\n            \"\"\"Called when the download has completed\"\"\"\n            pass\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Download files using requests and save them to a target path",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://www.github.com/takluyver/requests_download"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ada648f0af75cc62dc0b57013820d76c453962dc9ba1fffcfe4381b810b691bb",
                "md5": "55cfe46eb54086d21af217f408f4f6d5",
                "sha256": "994d9d332befae6616f562769bab163f08d6404dc7e28fb7bfed4a0a43a754ad"
            },
            "downloads": -1,
            "filename": "requests_download-0.1.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "55cfe46eb54086d21af217f408f4f6d5",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 5504,
            "upload_time": "2017-12-13T21:45:15",
            "upload_time_iso_8601": "2017-12-13T21:45:15.018110Z",
            "url": "https://files.pythonhosted.org/packages/ad/a6/48f0af75cc62dc0b57013820d76c453962dc9ba1fffcfe4381b810b691bb/requests_download-0.1.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "349d431a25538f158a3065a76a6311f40b7908f88a4d24efdbb0ca24f83bd614",
                "md5": "56f5163d97f6043056db89d314e83ad8",
                "sha256": "92d895a6ca51ea51aa42bab864bddaee31b5601c7e7e1ade4c27b0eb6695d846"
            },
            "downloads": -1,
            "filename": "requests_download-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "56f5163d97f6043056db89d314e83ad8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 2898,
            "upload_time": "2017-12-13T21:45:16",
            "upload_time_iso_8601": "2017-12-13T21:45:16.751172Z",
            "url": "https://files.pythonhosted.org/packages/34/9d/431a25538f158a3065a76a6311f40b7908f88a4d24efdbb0ca24f83bd614/requests_download-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2017-12-13 21:45:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "takluyver",
    "github_project": "requests_download",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "requests_download"
}
        
Elapsed time: 0.22316s