Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
docs/ | H | 23-Dec-2016 | - | 863 | 507 | |
requests_cache/ | H | 23-Dec-2016 | - | 1,138 | 849 | |
requests_cache.egg-info/ | H | 03-May-2022 | - | 221 | 137 | |
tests/ | H | 23-Dec-2016 | - | 862 | 662 | |
CONTRIBUTORS.rst | H A D | 23-Dec-2016 | 450 | 12 | 10 | |
HISTORY.rst | H A D | 23-Dec-2016 | 2.9 KiB | 143 | 83 | |
LICENSE | H A D | 23-Dec-2016 | 1.3 KiB | 25 | 21 | |
MANIFEST.in | H A D | 23-Dec-2016 | 247 | 13 | 9 | |
PKG-INFO | H A D | 23-Dec-2016 | 6.9 KiB | 221 | 137 | |
README.rst | H A D | 23-Dec-2016 | 1.8 KiB | 58 | 36 | |
example.py | H A D | 23-Dec-2016 | 743 | 28 | 16 | |
sandbox.py | H A D | 23-Dec-2016 | 315 | 13 | 8 | |
setup.cfg | H A D | 23-Dec-2016 | 88 | 9 | 6 | |
setup.py | H A D | 23-Dec-2016 | 1.3 KiB | 45 | 39 |
README.rst
1requests-cache 2--------------- 3 4Requests-cache is a transparent persistent cache for requests_ (version >= 1.1.0) library. 5 6.. _requests: http://python-requests.org/ 7 8.. image:: https://travis-ci.org/reclosedev/requests-cache.svg?branch=master 9 :target: https://travis-ci.org/reclosedev/requests-cache 10 11.. image:: https://coveralls.io/repos/reclosedev/requests-cache/badge.svg?branch=master&service=github 12 :target: https://coveralls.io/github/reclosedev/requests-cache?branch=master 13 14 15Usage example 16------------- 17 18Just write: 19 20.. code-block:: python 21 22 import requests 23 import requests_cache 24 25 requests_cache.install_cache('demo_cache') 26 27And all responses with headers and cookies will be transparently cached to 28`demo_cache.sqlite` database. For example, following code will take only 291-2 seconds instead of 10, and will run instantly on next launch: 30 31.. code-block:: python 32 33 for i in range(10): 34 requests.get('http://httpbin.org/delay/1') 35 36It can be useful when you are creating some simple data scraper with constantly 37changing parsing logic or data format, and don't want to redownload pages or 38write complex error handling and persistence. 39 40Note 41---- 42 43``requests-cache`` ignores all cache headers, it just caches the data for the 44time you specify. 45 46If you need library which knows how to use HTTP headers and status codes, 47take a look at `httpcache <https://github.com/Lukasa/httpcache>`_ and 48`CacheControl <https://github.com/ionrock/cachecontrol>`_. 49 50Links 51----- 52 53- **Documentation** at `readthedocs.org <https://requests-cache.readthedocs.io/>`_ 54 55- **Source code and issue tracking** at `GitHub <https://github.com/reclosedev/requests-cache>`_. 56 57- **Working example** at `Real Python <https://realpython.com/blog/python/caching-external-api-requests>`_. 58