Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pagination via async iterator #9

Open
ilyazub opened this issue Aug 12, 2021 · 0 comments
Open

Support pagination via async iterator #9

ilyazub opened this issue Aug 12, 2021 · 0 comments

Comments

@ilyazub
Copy link

ilyazub commented Aug 12, 2021

Python wrapper for SerpApi has search.pagination(): serpapi/google-search-results-python#19.

pages = search.pagination(0, 20)

urls = []

for result in pages:
	urls.append(result['serpapi_pagination']['next'])

In JavaScript, such a paginator can be done using the async generator function.

const paginator = search.pagination({ start: 0, end: 20 });

const organicResults = [];

for await (const page of paginator) {
  // page contains a single paginated output.
  organicResults.push(...page.organic_results);
}

Reference implementation from aws-sdk-js-v3.


Related to #6.

/cc @hartator @jvmvik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant