Use auto-ingest tool instead web page parsing #147

abuharsky opened this Issue Aug 24, 2011 · 5 comments


None yet
4 participants

Today Apple announce the availability of the auto-ingest tool, a new tool that lets you automatically retrieve your daily and weekly reports from the Sales and Trends module.

this is the source code:

public class Autoingestion
  public static void main(String[] paramArrayOfString)
    throws Throwable
    if ((paramArrayOfString.length < 6) || (paramArrayOfString.length > 7)) {
      System.out.println("Please enter all the required parameters.  For help, please download the latest User Guide from the Sales and Trends module in iTunes Connect.");

    String str1 = null;

    if ((paramArrayOfString.length == 7) && (null != paramArrayOfString[6])) {
      str1 = paramArrayOfString[6];
    } else {
      localObject1 = Calendar.getInstance();
      localObject2 = new SimpleDateFormat("yyyyMMdd");
      ((Calendar)localObject1).add(5, -1);

      str1 = ((SimpleDateFormat)localObject2).format(((Calendar)localObject1).getTime()).toString();

    Object localObject1 = null;
    Object localObject2 = null;

    String str2 = "USERNAME=" + URLEncoder.encode(paramArrayOfString[0], "UTF-8");
    str2 = str2 + "&PASSWORD=" + URLEncoder.encode(paramArrayOfString[1], "UTF-8");
    str2 = str2 + "&VNDNUMBER=" + URLEncoder.encode(paramArrayOfString[2], "UTF-8");
    str2 = str2 + "&TYPEOFREPORT=" + URLEncoder.encode(paramArrayOfString[3], "UTF-8");
    str2 = str2 + "&DATETYPE=" + URLEncoder.encode(paramArrayOfString[4], "UTF-8");
    str2 = str2 + "&REPORTTYPE=" + URLEncoder.encode(paramArrayOfString[5], "UTF-8");
    str2 = str2 + "&REPORTDATE=" + URLEncoder.encode(str1, "UTF-8");
      localObject2 = new URL("");

      localObject1 = (HttpsURLConnection)((URL)localObject2).openConnection();

      ((HttpsURLConnection)localObject1).setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

      OutputStreamWriter localOutputStreamWriter = new OutputStreamWriter(((HttpsURLConnection)localObject1).getOutputStream());

      if (((HttpsURLConnection)localObject1).getHeaderField("ERRORMSG") != null)
      else if (((HttpsURLConnection)localObject1).getHeaderField("filename") != null)
    catch (Exception localException)
      System.out.println("The report you requested is not available at this time.  Please try again in a few minutes.");
      if (localObject1 != null) {
        localObject1 = null;

  private static void getFile(HttpsURLConnection paramHttpsURLConnection)
    throws IOException
    String str = paramHttpsURLConnection.getHeaderField("filename");
    int i = 0;

    BufferedInputStream localBufferedInputStream = new BufferedInputStream(paramHttpsURLConnection.getInputStream());

    BufferedOutputStream localBufferedOutputStream = new BufferedOutputStream(new FileOutputStream(str));

    byte[] arrayOfByte = new byte[1024];

    while ((i = != -1) {
      localBufferedOutputStream.write(arrayOfByte, 0, i);

    System.out.println("File Downloaded Successfully ");

omz commented Aug 24, 2011

Very interesting... The requirement of entering a vendor ID is a bit annoying though, not sure yet how to deal with that.

It could be handled two ways. The login page under accounts could have another field added to it to hold the vendor id associated with an account (since I have only one account I don't know if more than one vendor id can be associated with a single login or not). The other way is that it could be parsed from the sales and trends page, contained in .


omz commented Aug 24, 2011

Working on this... The download works very well already (it's faster too) and the vendor ID is an additional field in the account settings.

I'd like to add a button to the login screen to automatically retrieve a list of available vendor IDs (or the single vendor ID), so that it doesn't have to be typed in manually, but it's not done yet.


omz commented Aug 24, 2011

Done. The auto-fill option for the vendor ID is somewhat experimental, so file bugs if it doesn't work...

omz closed this Aug 24, 2011

Hi guys. Thx for this work. So how can i parse downloaded file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment