My favorites | Sign in
Project Logo
                
Feeds:

Introduction

AppDailySales is a Python script that will download daily sales report files from the iTunes Connect web site.

How to Use

AppDailySales can be used as a stand-alone program or as part of another script.

Use as Stand-alone Program

Download the script appdailysales.py and run the command line:

usage: appdailysales.py [options]
Options and arguments:
-h     : print this help message and exit (also --help)
-a uid : your apple id (also --appleId)
-p pwd : your password (also --password)
-o dir : directory where download file is stored, default is the current working directory (also --outputDirectory)
-v     : verbose output, default is off (also --verbose)
-u     : unzip download file, default is off (also --unzip)
-d num : number of days to download, default is 1 (also --days)
-D mm/dd/yyyy : report date to download, -d option is ignored when -D is used (also --date)

You can also change the option variables located towards the top of the script file if you prefer to not use the command line options. However, this approach is not recommended with version 1.2 and greater of the script file.

Note: The script will return the exit code 0 if successful, otherwise exit code 1 is returned.

Use as Part of Another Script

As of Version 1.3 the AppDailySales script can be used as part of another script. Simply import appdailysales, set the report options, and call the downloadFile function. Here is a sample script file to help you get started:

#!/usr/bin/python

import sys
import traceback
import appdailysales

def main():
  options = appdailysales.ReportOptions()
  options.appleId = 'Your Apple Id'
  options.password = 'Your Password'
  options.outputDirectory = ''
  options.unzipFile = False
  options.verbose = False
  try:
    filename = appdailysales.downloadFile(options)
    print 'Report file downloaded: ', filename
  except:
    traceback.print_exc()
	
if __name__ == '__main__':
  main()

The function appdailysales.downloadFile will return the name of the last file downloaded. Be sure to include a try..except block around the call to gracefully handle any errors that might occur during the download.

Download Reports Multiple Days

As of version 1.6, there is a -d (also --days) option that is used to specify the number of days to download. The default is 1, which will download yesterday's report and keeps the script backwards compatible with the previous versions. Any value can be used for this option. However please note that as of now Apple only stores the last 7 days of daily sales reports. Using a value greater than 7 will result in a "report not available" error.

Why not add a check in the script to prevent values greater than 7? I decided not to include the check on the off chance Apple decides to provide access to reports older than 7 days.

Using BeautifulSoup

With the release of version 1.6 the script will use BeautifulSoup if available. BeautifulSoup is a Python HTML/XML parser that greatly simplifies screen-scraping web pages. BeautifulSoup is not required to use the AppDailySales script. However, if used then there is a less likely chance the AppDailySales script will break if and when Apple decides to change the layout of the web page.

Change History

Version 1.8

Version 1.7

Version 1.6

Version 1.5

Version 1.4

Version 1.3

Version 1.2

Version 1.1

Contributors

Special thanks goes out to the following individuals for contributing to this project:

Some Final Words

I created this script with the iPhone developer in mind. Being an iPhone developer myself I don't want to remember to download the daily sales report from yesterday's activity so I wrote this script. I have a cron job scheduled on a server that will download each day's report for me so I don't have to. Ain't automation great.

Other Useful Projects

For more useful projects visit the OtherUsefulProjects wiki page.









Hosted by Google Code