knox revisou este gist . Ir para a revisão
1 file changed, 12 insertions
yfinance-11.py(arquivo criado)
@@ -0,0 +1,12 @@ | |||
1 | + | from requests import Session | |
2 | + | from requests_cache import CacheMixin, SQLiteCache | |
3 | + | from requests_ratelimiter import LimiterMixin, MemoryQueueBucket | |
4 | + | from pyrate_limiter import Duration, RequestRate, Limiter | |
5 | + | class CachedLimiterSession(CacheMixin, LimiterMixin, Session): | |
6 | + | pass | |
7 | + | ||
8 | + | session = CachedLimiterSession( | |
9 | + | limiter=Limiter(RequestRate(2, Duration.SECOND*5)), # max 2 requests per 5 seconds | |
10 | + | bucket_class=MemoryQueueBucket, | |
11 | + | backend=SQLiteCache("yfinance.cache"), | |
12 | + | ) |
Próximo
Anterior