mirror of
https://github.com/ihabunek/toot
synced 2025-02-07 23:58:39 +01:00
Add anon variant of get_paged
This commit is contained in:
parent
e0f3888370
commit
61fe478bf3
16
toot/http.py
16
toot/http.py
@ -91,6 +91,22 @@ def anon_get(url, params=None):
|
||||
return process_response(response)
|
||||
|
||||
|
||||
def anon_get_paged(url, params=None):
|
||||
if params:
|
||||
url += f"?{urlencode(params)}"
|
||||
|
||||
while url:
|
||||
response = anon_get(url)
|
||||
yield response
|
||||
url = _next_url(response)
|
||||
|
||||
|
||||
def _next_url(response):
|
||||
next_link = response.links.get("next")
|
||||
if next_link:
|
||||
return next_link["url"]
|
||||
|
||||
|
||||
def post(app, user, path, headers=None, files=None, data=None, json=None, allow_redirects=True):
|
||||
url = app.base_url + path
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user