thedoedoeblog

Musings of a small game development team

Scraping iTunes: Finishing Up

Written by Bill Soistmann on March 26, 2009 at 1:03 pm

Last week I started a series of posts detailing how I scraped the iTunes store and how you might do the same for your needs.

Today I will add just one last thing and we will call this a wrap.

In order to grab the rating for another country’s iTunes store, you simply pass in a numeric country code. To make things nice and user friendly, we can add a hash that maps each code to a string that makes more sense to us.

my %stores = ("US", "143441",
"Australia", "143460",
"Brazil", "143503",
"Chile", "143483",
"Columbia", "143501",
"Croatia", "143494",
"Denmark", "143458",
"ElSalvador", "143506",
"Finland", "143447",
"Greece", "143448",
"HongKong", "143463",
"India", "143467",
"Ireland", "143449",
"Italy", "143450",
"Kuwait", "143493",
"Luxemburg", "143451",
"Mexico", "143468",
"NewZealand", "143461",
"Austria", "143445",
"Panama", "143485",
"Philippines", "143474",
"Portugal", "143453",
"Romania", "143487",
"SaudiArabia", "143479",
"Singapore", "143464",
"Slovenia", "143499",
"SriLanka", "143486",
"Taiwan", "143470",
"Turkey", "143480",
"UnitedKingdom", "143444",
"Vietnam", "143471",
"Belgium", "143446",
"China", "143465",
"Czech", "143489",
"Spain", "143454",
"Guatemala", "143504",
"Indonesia", "143476",
"Korea", "143466",
"Malaysia", "143473",
"Norway", "143457",
"Peru", "143507",
"Qatar", "143498",
"Switzerland", "143459",
"SouthAfrica", "143472",
"Thailand", "143475",
"Venezuela", "1435021",
"Canada", "143455",
"Germany", "143443",
"Hungary", "143482",
"Lebanon", "143497",
"Pakistan", "143477",
"Russia", "143469",
"Sweden", "143456",
"Japan", "143462",
"CostaRica", "143495",
"Israel", "143491",
"Poland", "143478",
"UnitedArabEmirates", "143481",
"France", "143442",
"Slovenia", "143496",
"Netherlands", "143452",
"Argentina", "143505"
);

Then we change this line

$coCode = $data{'country'};

to this

$coCode = ($data{'country'})?$data{'country'}:"US";

and this line

$store = 143441;

to this

$store = $stores[$coCode];

That’s all there is to it. I saved this for last because of all the extra code, but it’s a very easy edit.

You can grab the current version and give it a shot. Have fun.

This is the last post in a series of posts which start here.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.