OHO's Blog

My 2 cents about everything!

Extract iTunesConnect App Lists and Status

Perl script for getting app list and status

In my job, I handle iTunesConnect accounts with lots of apps, and I needed today to create and excell file with all my iTunesConnect apps list.

After a quick browse on Google I found the Perl class HTML::TableExtract that does extract tables from an HTML document.

So, playing around with it, I quickly wrote the script I needed. I thought I would share it here so that I can find it back when needed to parse tables from HTML again.

You will need to save your iTunesConnect Search Result page (when you click See All on Manage Your App) in an html file. You know the page that show a table of all your apps with “App Name”, “App Type”, “Version”, “Status”, etc.?

The script take this html file as an input and write in standart output a csv type of content (apps per line with columns separated by semicolon).

Prerequesit:

    perl -MCPAN -eshell
    install HTML::TableExtract

Synthax:

    ITCAppList.pl <saved-itunesconnect-html-page.html> > result.csv
(ITCAppList.pl) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl

# Author: Olivier HO-A-CHUCK
# Date: Juen 18th 2013
# License: Do What You Want with it! Just comes with no garantie.

use HTML::TableExtract;

sub trim;
sub removeBR;

local $/;
open(FILE, 'iTunesConnect.html') or die "Can't read file 'filename' [$!]\n";  
$document = <FILE>; 
close (FILE); 
$document = removeBR($document); # Quick and dirty trick for apps with 2 status (like ready for sales and In Review).

$te = HTML::TableExtract->new( headers => [qw(AppName AppType Version Status AppleID LastModified)] );
$te->parse($document);


my $string = "App Name;App Type;Version;Status;Apple ID;Last Modified\n";
# Examine all matching tables
foreach $ts ($te->tables) {
  foreach $row ($ts->rows) {
      $string = $string . trim(@$row[0]) . ";" . trim(@$row[1]) . ";" . trim(@$row[2]) . ";" . trim(@$row[3]) . ";" . trim(@$row[4]) . ";" . trim(@$row[5]) . "\n";           
  }
}

print $string;

# Perl trim function to remove whitespace from the start and end of the string
sub trim
{
  my $string = shift;
  $string =~ s/^\s+//;
  $string =~ s/\s+$//;
  return $string;
}

sub removeBR
{
  my $string = shift;
  $string =~ s/<br>.*//g;
  return $string;
}

As usual, any comment or improvements are welcome.

Note: if I have time I will probably write a quick Chrome Automation Service/Script to do it right from the browser.

Comments