mirror of
https://github.com/osmarks/meme-search-engine.git
synced 2025-08-04 21:03:47 +00:00
Fix crawler (rate limit changes)
This commit is contained in:
parent
43ff9215fb
commit
fc6d0c9409
@ -9,6 +9,10 @@ import sys
|
|||||||
|
|
||||||
async def fetch_list_seg(sess, list_url, query):
|
async def fetch_list_seg(sess, list_url, query):
|
||||||
async with sess.get(list_url + ".json", params=query) as res:
|
async with sess.get(list_url + ".json", params=query) as res:
|
||||||
|
if rate_limit := res.headers.get("x-ratelimit-remaining"):
|
||||||
|
rl = float(rate_limit)
|
||||||
|
if rl <= 5.0:
|
||||||
|
await asyncio.sleep(float(res.headers["x-ratelimit-reset"]))
|
||||||
return await res.json()
|
return await res.json()
|
||||||
|
|
||||||
async def fetch_past(sess, list_url, n):
|
async def fetch_past(sess, list_url, n):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user