import re from geo import read_url def get_countries(): return get_data('country') def get_data(type): html = read_url('http://www.imdb.com/' + type) regexp = '(.*?)\n?' results = re.compile(regexp).findall(html) data = sorted(map(lambda x: { 'code': x[0], 'name': x[1] }, results), key=lambda x: x["code"]) return data def get_languages(): return get_data('language')