From 1fcd1f385e53688b63ed6ebcd0b6ce42531fd01c Mon Sep 17 00:00:00 2001 From: Denis Washington Date: Wed, 12 Jun 2024 17:43:01 +0200 Subject: [PATCH] feat: double the number of reviews per API request After some experimentation, I found out that 20 is the maximum page size allowed by the App Store's API (the default is 10). So specify that unless the `limit` passed to `reviews()` is lower than 20, in which case we use that instead. --- src/app_store_web_scraper/_entry.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app_store_web_scraper/_entry.py b/src/app_store_web_scraper/_entry.py index 6ec4494..e2a96e3 100644 --- a/src/app_store_web_scraper/_entry.py +++ b/src/app_store_web_scraper/_entry.py @@ -40,6 +40,8 @@ class AppReview: r'', ) +_REVIEWS_PAGE_SIZE = 20 + class AppStoreEntry: """ @@ -75,11 +77,12 @@ def reviews(self, limit: int = 0) -> Iterator[AppReview]: params = { "platform": "web", "additionalPlatforms": "appletv,ipad,iphone,mac", + "sort": "-date", + "limit": str(min(limit, _REVIEWS_PAGE_SIZE)) + if limit > 0 + else str(_REVIEWS_PAGE_SIZE), } - if limit > 0: - params["limit"] = str(limit) - query_string = urllib.parse.urlencode(params) url = f"{path}?{query_string}" review_count = 0