def fetch_all(page=1): page, last_page = page, Startup.num_pages() while page <= last_page: response = Thing.api().get('startups', {'filter': 'raising', 'page': page}) page = response['page'] + 1 for startup in response['startups']: yield Startup(startup)
def num_pages(): return Thing.api().get('startups', {'filter': 'raising', 'per_page': 1})['last_page']