mirror of
https://github.com/osmarks/meme-search-engine.git
synced 2026-11-28 01:53:13 +00:00
Fix crawler (rate limit changes)
This commit is contained in:
1 parent
43ff9215fb
commit
fc6d0c9409
1 file changed
+4
@@ -9,6 +9,10 @@ import sys
|
||||
|
||||
async def fetch_list_seg(sess, list_url, query):
|
||||
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()
|
||||
|
||||
async def fetch_past(sess, list_url, n):
|
||||
|
||||
Reference in new issue
Block a user