Skip to content

Instantly share code, notes, and snippets.

@gmale
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmale/9734399 to your computer and use it in GitHub Desktop.
Save gmale/9734399 to your computer and use it in GitHub Desktop.
Just a quick script I whipped together so I can see the latest android stats. Beware: I'm not a Python dev so plz excuse the crappy codez.
#! /usr/bin/env python3
import re
import requests
import json
from datetime import datetime
link = "http://developer.android.com/about/dashboards/index.html"
contents = requests.get(link).text
currentYear = datetime.now().year
date_text = re.findall("Data collected during.*%s" % currentYear, contents)[0]
stats = re.findall("VERSION_DATA =([^;]+);", contents, re.DOTALL)[0].strip()
json = json.loads(stats)
data = json[0]['data']
def printVersion(info):
print("[API {1:2d}] - {0:20}: {2:5.1f} %".format(info['name'], info['api'], float(info['perc'])))
print("\n----------------------------------\nANDROID USAGE (%s):\n----------------------------------\n" % date_text)
android4_0 = 0.0
android4_1 = 0.0
androidOld = 0.0
for d in data:
printVersion(d)
if d['api'] > 14:
android4_0 += float(d['perc'])
if d['api'] > 15:
android4_1 += float(d['perc'])
else:
androidOld += float(d['perc'])
print("\n{0:31}: {1:5.1f} %".format("4.0 and above", float(android4_0)))
print("{0:31}: {1:5.1f} %".format("4.1 and above", float(android4_1)))
print("{0:31}: {1:5.1f} %".format("older versions", float(androidOld)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment