oxjs/tools/geo/py/imdb.py
2011-05-23 21:38:52 +02:00

18 lines
454 B
Python

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 = '<a href="/' + type + '/(.*?)">(.*?)\n?</a>'
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')