Support pagination for getJson#3
Merged
sebastianquek merged 11 commits intomasterfrom Jan 18, 2023
Merged
Conversation
f8a618e to
9f4a96d
Compare
fd971a9 to
b453ac7
Compare
b453ac7 to
2ce4c04
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Handles #2
This PR implements "Approach 2: Next method" as mentioned in the above issue. Main reasons are that it supports callbacks and it can be used to create an approach similar to Approach 3.
Note that this PR doesn't cover pagination support for
getJsonBySearchId.Tests
I've added tests for 6 of the 7 types of pagination approaches:
google_mapsapple_reviewsbaiduebayhome_depotgoogle_scholar_profilesOffset + page: The only engine that uses this approach,google_product, relies on an approach that is similar to thetokenonly approach.Additional notes
Pagination using the
.next()method is currently only supported by engines that respond with aserpapi_pagination.nextproperty.google_jobsallows for pagination via thestartoffset param, but currently does not return aserpapi_pagination.nextproperty. For these cases, you need to send in thestartoffset param manually.pagination.nextis used instead. This is for thegoogle_scholar_profilesengine.Although
yahoo_shoppingreturns aserpapi_pagination.nextproperty, I've excluded it as there are currently some issues with itserpapi_pagination.nextURL when using page parameter public-roadmap#562serpapi_paginationreturned when there are no results public-roadmap#563There is a check if the next parameters are equal to the current parameters. This check is based on this issue: [Ebay Search API] Pagination returns the same results public-roadmap#144.
I couldn't replicate it for Ebay, but nonetheless, will keep it in as a safeguard.{ q: "coffee", start: 30 }but the next params extracted frompage1are{ kl: "us-en", q: "coffee", start: 30}. This difference means thatpage1.nextis returned. It's only after obtainingpage2that the current params (which includeskl) and next params match, implying there's no next page.