Skip to content
This repository was archived by the owner on Nov 18, 2019. It is now read-only.

Commit e5b7389

Browse files
Adds method for content rating,title,min and max downloads.
1 parent 265f3fa commit e5b7389

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

playstats/appstat.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,37 @@ def size(self):
7777
if len(match) == 1:
7878
return match[0].text.strip()
7979
return 'Unavailable'
80+
81+
def content_rating(self):
82+
# Returns the content rating for the app.
83+
selector = CSSSelector('div.content[itemprop="contentRating"]')
84+
match = self.tree.xpath(selector.path)
85+
if len(match) == 1:
86+
return match[0].text.strip()
87+
return 'Unavailable'
88+
89+
def min_downloads(self):
90+
# Returns the minimum number of downloads for the app.
91+
# This method is not useful enough.
92+
# Actually Google Play doesn't display the actual
93+
# number of downloads on the website it displays a range
94+
# for eg. 100,000,000 - 500,000,000
95+
selector = CSSSelector('div.content[itemprop="numDownloads"]')
96+
match = self.tree.xpath(selector.path)
97+
return int(match[0].text.split('-')[0].replace(',', ''))
98+
99+
def max_downloads(self):
100+
# Returns the maximum number of downloads for the app.
101+
# This method is not useful enough.
102+
# Actually Google Play doesn't display the actual
103+
# number of downloads on the website it displays a range
104+
# for eg. 100,000,000 - 500,000,000
105+
selector = CSSSelector('div.content[itemprop="numDownloads"]')
106+
match = self.tree.xpath(selector.path)
107+
return int(match[0].text.split('-')[1].replace(',', ''))
108+
109+
def title(self):
110+
# Returns the title of the app as on Google Play.
111+
selector = CSSSelector('.id-app-title')
112+
match = self.tree.xpath(selector.path)
113+
return match[0].text

0 commit comments

Comments
 (0)