Skip to content

Commit

Permalink
Fix crawler (rate limit changes)
Browse files Browse the repository at this point in the history
  • Loading branch information
osmarks committed Jul 15, 2024
1 parent 43ff921 commit fc6d0c9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions meme-rater/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

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):
Expand Down

0 comments on commit fc6d0c9

Please sign in to comment.