How to scrape Google Play Store data in Python
Two routes: the open-source google-play-scraper package for small jobs, an API for anything that has to run every day.
Route 1: a scraping library
The open-source google-play-scraper package fetches a store page and parses it:
pip install google-play-scraper
from google_play_scraper import app
d = app("com.whatsapp", lang="en", country="us")
print(d["title"], d["installs"], d["score"])It is great for a notebook. In production you will meet three problems: rate limits (Google answers with 429s and captchas once you send many requests from one IP), markup changes (parsers break without warning), and memory (when an app is removed, the page is gone and so is its data).
Route 2: ask an index that is already scraped
import os, requests
r = requests.get("https://apiplay.cc/api/v1/app",
params={"id": "com.whatsapp"},
headers={"X-API-Key": os.environ["API_KEY"]}, timeout=30)
app = r.json()["app"]
print(app["title"], app["installs"]["label"], app["rating"]["score"])Same fields, no proxies. Removed apps still answer, with status.removed set.
Scraping a whole category
Instead of crawling category pages, filter:
params = {"category": "GAME_PUZZLE", "min_installs": 100000, "per": 100, "page": 1}
r = requests.get("https://apiplay.cc/api/v1/search", params=params, headers=H).json()
for a in r["results"]:
print(a["id"], a["installs"]["min"], a["rating"]["score"])Loop over page until r["pages"]. Each page of up to 100 apps costs 2 credits.
Which one to pick
- One-off analysis of a few hundred apps: the library is fine.
- A daily job, thousands of apps, or history of removed apps: use the API.