Every iPhone developer wants to know how his apps are doing. While Apple tells you about sales and traffic, you can't really compare your app to the competition. Although this information is available in iTunes in the form of a "ranking" of the top 100 applications in each category, there is no way of getting to it other than clicking through all the pages in iTunes by hand. What makes things worse is that there are many stores, and the rankings will be different in each store and category.
Not too long ago, Ben Chatelain wrote a perl script, based on Erica Sadun's previous work, to exctract the rankings for an app identified by its ID from any iTunes Application Store in the world. Unfortunately, it seems that Apple keeps changing the XML format that these web services return. The original Perl script by Ben was subsequently modified by the guys at touchcentric to make it faster and easier to use.
Last week I downloaded the perl script from their website and tried to get statistics for our new app, Point Don't Shout. As it turned out, the script didn't work for me. I traced it down to the regular expression that digests the XML returned by Apple and extracts an app's rank, id and name. It seems that Apple was kind enough to change their format, once again.
I set out to fixing this issue and modified the Perl script again. However, as the format has become more complicated, I decided to properly parse the XML using XML::TreeBuilder, a nice and simple XML DOM style parser for Perl. I also cleaned up the code and removed some unused functions as well as modifying the way caching was handled previously.
The new script can be downloaded here. Please let me know if you run into problems, or if you are overjoyed to use this little piece of code.




Thanks for providing this script, it works great for me.
how do you properly use this script again?
As tweeted yesterday: download the script and run with args
./app_rank.pl -k -c
You can leave out both arguments, in which case it defaults to checking the top 100 overall apps in all countries. You can find your app id from iTunes by right-clicking on the link to your app in the store and copying the path. From the URL, extract the bit where it says: id=… up until the following “&” character.
If you don’t have XML::TreeBuilder installed, run this on the command line:
sudo cpan -i XML::TreeBuilder
Hope that helps,
Benjamin