JoMingyu / google-play-scraper

Google play scraper for Python inspired by <facundoolano/google-play-scraper>
MIT License
757 stars 207 forks source link

[FEAT-REQ] To get ratings & reviews based on time frame with or without comment. #194

Closed hisham-dev92 closed 10 months ago

hisham-dev92 commented 11 months ago

Is your feature request related to a problem? I was trying to get fetch all reviews from Jan 1st till Mar 31st to do some analysis.

Describe the solution you'd like Would be nice if there was an option to select the time frame.

Thanks in Advance.

Plouffi commented 11 months ago

Hello,

I don't think it is possible because Google doesn't provide advanced search on reviews in playstore. (edit: without crawling throught all reviews) Best I can suggest is to modify the reviews feature by adding a datetime parameter and stop the fetching loop when is reached.

def reviews(
    app_id: str,
    date: datetime = None, # Desired date to stop
    lang: str = "en",
    country: str = "us",
    sort: Sort = Sort.NEWEST,
    count: int = 100,
    filter_score_with: int = None,
    continuation_token: _ContinuationToken = None,
) -> Tuple[List[dict], _ContinuationToken]:

# ...
# Some code...
# ...

        for review in review_items:
            extracted_review = {
                k: spec.extract_content(review)
                for k, spec in ElementSpecs.Review.items()
            }
            # Stop when the desired date is reached
            if date is not None and extracted_review['at'] < date:
                break

            result.append(extracted_review)

# ...
# Some code...
# ...

Edit: You can add another datetime parameter to avoid appending reviews before a certain date

JoMingyu commented 10 months ago

@Plouffi answered correctly. Thanks.