• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

docs/H23-Dec-2016-863507

requests_cache/H23-Dec-2016-1,138849

requests_cache.egg-info/H03-May-2022-221137

tests/H23-Dec-2016-862662

CONTRIBUTORS.rstH A D23-Dec-2016450 1210

HISTORY.rstH A D23-Dec-20162.9 KiB14383

LICENSEH A D23-Dec-20161.3 KiB2521

MANIFEST.inH A D23-Dec-2016247 139

PKG-INFOH A D23-Dec-20166.9 KiB221137

README.rstH A D23-Dec-20161.8 KiB5836

example.pyH A D23-Dec-2016743 2816

sandbox.pyH A D23-Dec-2016315 138

setup.cfgH A D23-Dec-201688 96

setup.pyH A D23-Dec-20161.3 KiB4539

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