Giter Site home page Giter Site logo

parkerhancock / requests-cache Goto Github PK

View Code? Open in Web Editor NEW

This project forked from requests-cache/requests-cache

0.0 1.0 0.0 1013 KB

Transparent persistent cache for http://python-requests.org/ library ⛺

Home Page: http://pypi.python.org/pypi/requests-cache

License: BSD 2-Clause "Simplified" License

Python 99.80% Shell 0.20%

requests-cache's Introduction

Requests-Cache

Build Coverage Documentation PyPI PyPI - Python Versions PyPI - Format Code Shelter

Summary

requests-cache is a transparent, persistent HTTP cache for the python requests library. It's a convenient tool to use with web scraping, consuming REST APIs, slow or rate-limited sites, or any other scenario in which you're making lots of requests that are expensive and/or likely to be sent more than once.

See full project documentation at: https://requests-cache.readthedocs.io

Features

Quickstart

First, install with pip:

pip install requests-cache

Next, use requests_cache.CachedSession to send and cache requests. To quickly demonstrate how to use it:

This takes ~1 minute:

import requests

session = requests.Session()
for i in range(60):
    session.get('http://httpbin.org/delay/1')

This takes ~1 second:

import requests_cache

session = requests_cache.CachedSession('demo_cache')
for i in range(60):
    session.get('http://httpbin.org/delay/1')

The URL in this example adds a delay of 1 second, simulating a slow or rate-limited website. With caching, the response will be fetched once, saved to demo_cache.sqlite, and subsequent requests will return the cached response near-instantly.

If you don't want to manage a session object, requests-cache can also be installed globally:

requests_cache.install_cache('demo_cache')
requests.get('http://httpbin.org/delay/1')

Next Steps

To find out more about what you can do with requests-cache, see:

requests-cache's People

Contributors

aaron-mf1 avatar andrewkittredge avatar ar90n avatar borisdan avatar chengguangnan avatar christopher-dg avatar craigls avatar dependabot[bot] avatar edwardbetts avatar fdemmer avatar garrett-r avatar glensc avatar jacebrowning avatar jkwill87 avatar jsemric avatar jwcook avatar libbkmz avatar mbarkhau avatar meowcoder avatar mgax avatar mgedmin avatar michaelbeaumont avatar msabramo avatar olivierdalang avatar parkerhancock avatar reclosedev avatar rgant avatar shiftinv avatar themiurgo avatar yetanothernerd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.