Code Monkey home page Code Monkey logo

apple-app-reviews-scraper's Introduction

Python Version License

Apple App Store Reviews Scraper

Apple App Store reviews scraper. Reviews are fetched using Apple's API, as the webpage of each app only displays a few reviews.

It is adapted from app-store-scraper. I converted the classes to functions for ease of debugging and removed some redundant elements such as the date filter as Apple does not allow reviews to be sorted by date. Generally, the larger the offset, the older the reviews tend to be.

This port is motivated by the rate limiting that is quickly encountered when using the original package. To address this, I added a default delay and backoff strategy. With the current configuration, it has been tested to scrape ~15,000 reviews with no rate limiting.

Includes two simple functions get_token and fetch_reviews, which are used to retrieve an authentication token and fetch app reviews, respectively.

Usage

First, set some some user_agents.

user_agents = [
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15',
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36',
]

Obtaining a Bearer Token

To fetch app reviews from the Apple App Store API, you need to obtain an authentication token. The get_token function retrieves this token.

from apple_app_reviews_scraper import get_token

# Provide the necessary parameters
country = 'sg'
app_name = 'your-app-name' # can be named anything, really
app_id = 'your-app-id'

# Get token
token = get_token(country, app_name, app_id, user_agents)

print(f"Authentication Token: {token}")

Fetching App Reviews

Once you have obtained the authentication token, use the fetch_reviews function to fetch app reviews.

from apple_app_reviews_scraper import fetch_reviews
import pandas as pd

country = 'sg'
app_name = 'your-app-name' # can be named anything, really
app_id = 'your-app-id'

# Call the function
reviews, offset, status_code = fetch_reviews(country, app_name, app_id, user_agents, token)

# Preview as a DataFrame
df = pd.json_normalize(reviews)

JSON structure of a single review:

{'id': '2801236969',
 'type': 'user-reviews',
 'attributes': {'date': '2022-06-30T08:36:15Z',
  'review': "This is a great app!",
  'rating': 5,
  'isEdited': False,
  'userName': 'updog',
  'title': 'Nice'},
 'offset': '21',
 'n_batch': 20,
 'app_id': '324684580'}

If developer responded:

 {'id': '9700279414',
 'type': 'user-reviews',
 'attributes': {'date': '2023-03-11T01:06:51Z',
  'developerResponse': {'id': 35337720,
   'body': "Thanks for your feedback!",
   'modified': '2023-03-12T17:16:37Z'},
  'review': 'I love this app!',
  'rating': 4,
  'isEdited': False,
  'title': 'Great',
  'userName': 'Nice'},
 'offset': '21',
 'n_batch': 20,
 'app_id': '913943275'}

Authors

Credits

apple-app-reviews-scraper's People

Contributors

glennfang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.