I wrote a post about scraping Google’s Developer Console a year ago. A site visitor told me about his problems with this solution so I decided to help him out with a different option – a simple python script. It requires less prerequesites to be installed – only mechanize (sudo easy_install mechanize or sudo pip install mechanize).
In case you did not notice, when you log in to the Developer console, you can click on the Reports option and then statistics. There you have to write the name of your application and you will be presenteed with the statistics in zip files. I’m only interested in number of downloads and how many people actually use my application. Right click on Latest monthy install report and copy its url, we will be needing it shortly. For example, in my case the url would look something similar to https://play.google.com/apps/publish/bulkreports/download?period=2015_07&report_type=STATS_INSTALLS&package=com.example.application&dev_acc=0358642832969076833.
As you can see from the url, it contains a time period. The zip file also contains several csv files, that display daily statistics. I’ve made a simple script that downloads current months statistics in a zip file, extracts it and outputs the very last entry. That way I get the number of downloads and how many people have my app installed on their device. The script is available over here.
Before running it, you will need to do a few things first though. As stated before, install mechanize first. Get a hold of your dev_acc – it should be in the url you copied before. Take a look at the line that starts with result=br.open (should be number 22). Replace my dev_acc id with yours. Also replace the example package name with your application package name. Definitively replace the email and password with an account that has access to the developer console. I’m using /home/peter/production/scrape/ folder to hold the downloaded zip and csv files. Change that according to your needs.
Now you can give it a go! The script first opens the url to the zip file that contains all of the statistics for the current month. It cannot, because it’s not authorised – it then logs in to the Developer console. In a moment the zip file is saved to the path you want. The file that ends with overview.csv is opened, because it’s the only one that contains the neeeded statistics. With the help of tail and cut, the needed information is parsed out. Then you can do what you want with it.