Quantcast
Channel: Idiot Inside
Viewing all articles
Browse latest Browse all 26

Get android app downloads count and rating from Google Play Store

$
0
0

Get android app downloads count and rating from Google Play Store

Google doesn’t provide any API or Widgets to display android application downloads count and rating on your website. Since there is no official google api that provides this data, we need a custom solution to get android app downloads count and rating from playstore. Since scraping is the best way to parse a web page and retrieve data from the web page, we are going to scrap data from the android app page on google playstore.

This script will help you to get android app downloads count and rating from google playstore.

This is experimental and only for learning purpose.
import requests
from bs4 import BeautifulSoup


class GooglePlay(object):
    def get_playstore_info(self, app):
        # Fetch android app page
        app_page = requests.get(app)

        # Provide the app page content to BeautifulSoup parser
        soup = BeautifulSoup(app_page.content, 'html.parser')

        # Get value by id
        title = soup.select('div.id-app-title')

        # Get value from meta tag url
        url = soup.find("meta", {"itemprop": "url"})['content']

        # Get value from meta tag rating
        ratingsValue = soup.find("meta", {"itemprop": "ratingValue"})['content']
        ratingsCount = soup.find("meta", {"itemprop": "ratingCount"})['content']

        # Get value by attribute
        num_downloads = soup.find("div", {"itemprop": "numDownloads"}).text

        num_downloads_abs = num_downloads.split("-")[1]

        app_details = dict()
        app_details['title'] = title[0].text
        app_details['url'] = url
        app_details['rating'] = float(ratingsValue)
        app_details['rated_by'] = int(ratingsCount)
        app_details['downloads'] = int(num_downloads_abs.replace(" ", "").replace(",", ""))
        app_details['downloads_range'] = num_downloads
        return app_details


playstore = GooglePlay()

app_url = "https://play.google.com/store/apps/details?id=com.whatsapp"
app_details =  playstore.get_playstore_info(app_url)

print app_details

Want to improve this code? Fork us on GitHub

This script will return a dictionary of android app details like application title, URL, rating and rated by people people count and number of downloads as well as downloads range.

{
'rating': 4.430968761444092, 
'title': 'WhatsApp Messenger', 
'url': 'https://play.google.com/store/apps/details?id=com.whatsapp', 
'downloads': 5000000000, 
'downloads_range': ' 1,000,000,000 - 5,000,000,000 ', 
'rated_by': 38583950
}

GET ANDROID APP DOWNLOADS COUNT AND RATING FROM GOOGLE PLAY STORE

Libraries used

  1. BeautifulSoup (html parser) Install by pip install beautifulsoup4
  2. python requests (http requests wrapper library) Install by pip install requests

Viewing all articles
Browse latest Browse all 26

Trending Articles