forked from sureshdsk/py-codes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoogle-play-store-app-download-count.py
42 lines (30 loc) · 1.38 KB
/
google-play-store-app-download-count.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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