Reputation: 477
I want to view the stars vote by users for my app in Google play. Any solution for it?
Upvotes: 0
Views: 1622
Reputation: 1724
One way to do it is by parsing the data from inline JSON located in the HTML. An example approach of scraping app reviews count and rating in Python using beautifulsoup
, lxml
, requests
libraries, and a regular expression.
Code and full example in the online IDE:
# Super-Mario game is being scraped in this example:
# https://play.google.com/store/apps/details?id=com.nintendo.zara&gl=US
from bs4 import BeautifulSoup
import requests, lxml, re, json
params = {
"id": "com.nintendo.zara", # app name
"hl": "en", # language
"gl": "us" # country
}
headers = {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3538.102 Safari/537.36"
}
html = requests.get("https://play.google.com/store/apps/details", params=params, headers=headers, timeout=10)
soup = BeautifulSoup(html.text, "lxml")
# [12] index <script> position is not changing. Other <script> tags position are changing.
# [12] index is a basic app information.
# https://regex101.com/r/DrK0ih/1
basic_app_info = json.loads(re.findall(r"<script nonce=\".*\" type=\"application/ld\+json\">(.*?)</script>", str(soup.select("script")[12]), re.DOTALL)[0])
app_rating = round(float(basic_app_info["aggregateRating"]["ratingValue"]), 1) # 4.287856 -> 4.3
app_reviews = basic_app_info["aggregateRating"]["ratingCount"]
print(app_rating, app_reviews, sep="\n")
# 4.0
# 1619960
Create search params as a dictionary:
# https://docs.python-requests.org/en/master/user/quickstart/#passing-parameters-in-urls
params = {
"id": "com.nintendo.zara", # app name
"hl": "en", # language
"gl": "us" # country
}
Create headers to act as a "real" user visit so Google won't treat your request as a bot request right away:
# https://docs.python-requests.org/en/master/user/quickstart/#custom-headers
headers = {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3538.102 Safari/537.36"
}
Make a request, pass params
and headers
to the request and create a BeautifulSoup
object where HTML will be processed and parsed:
html = requests.get("https://play.google.com/store/apps/details", params=params, headers=headers, timeout=10)
soup = BeautifulSoup(html.text, "lxml")
Find <scprit>
tags, parse the needed data from the [12]
index <scprit>
tag where all basic app info is located, and then parse only JSON part via regular expression:
# https://regex101.com/r/DrK0ih/1
basic_app_info = json.loads(re.findall(r"<script nonce=\".*\" type=\"application/ld\+json\">(.*?)</script>", str(soup.select("script")[12]), re.DOTALL)[0])
json.loads()
will convert JSON string to a Python dictionary.Parsing data via regular expression from an actual JSON response is safer than scraping via CSS selectors. CSS selectors might be changed, and, in this case, you have to render the page in order to scrape the data which will become slow if using browser automation.
Access the data and print it:
app_rating = round(float(basic_app_info["aggregateRating"]["ratingValue"]), 1) # 4.287856 -> 4.3
app_reviews = basic_app_info["aggregateRating"]["ratingCount"]
print(app_rating, app_reviews, sep="\n")
# 4.0
# 1619960
If you want to understand how to scrape more data in Python, you can read the rest on Scrape Google Play Store App in Python blog post of mine.
If you want to use a complete solution, you can use google-play-scraper
for Python or google-play-scraper
for JavaScript which are free, or Google Play Store API from SerpAPI which is a paid API with a free plan that handles scraping, bypass blocing, scaling for the user.
Upvotes: 1
Reputation: 4787
Thats pretty simple. Go to Google Play Store :https://play.google.com/store?hl=en
Search for your in the top bar. If you find your app ,you can see the stars vote.
Hope this helps.
Upvotes: 0
Reputation: 7435
Unfortunately there is no API currently for the developer statistics. Apps like Andlyitics use screen scraping and that is why they have to be updated when ever the console changes.
Following from there play store page:
Please notice that Google doesn't provide a stable API to get download and rating stats. Therefore Andlytics might not work properly if something changes in the Android Market. In that case please be patient while we try to catch up with the changes.
Upvotes: 1
Reputation: 691
go to https://play.google.com/store/apps/details?id=
You will find ratings on right side and bottom of the page. If you want o see user reviews. Click on user reviews tab shown above the Description
Upvotes: 0