Skip to content

Commit

Permalink
feat: double the number of reviews per API request
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
denisw committed Jun 12, 2024
1 parent e9f97e2 commit 1fcd1f3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/app_store_web_scraper/_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class AppReview:
r'<meta name="web-experience-app/config/environment" content="(.+?)">',
)

_REVIEWS_PAGE_SIZE = 20


class AppStoreEntry:
"""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1fcd1f3

Please sign in to comment.