# -*- coding: UTF-8 -*- # vi:si:et:sw=4:sts=4:ts=4 import re import ox.cache from ox.cache import read_url from ox.html import strip_tags from ox.text import find_re, remove_special_characters import imdb def get_id(url): return url.split("/")[-1] def get_url(id): return "http://www.criterion.com/films/%s" % id def get_data(id, timeout=ox.cache.cache_timeout, get_imdb=False): ''' >>> get_data('1333').get('imdbId') u'0060304' >>> get_data('236')['posters'][0] u'http://s3.amazonaws.com/criterion-production/release_images/1586/ThirdManReplace.jpg' >>> get_data('786')['posters'][0] u'http://s3.amazonaws.com/criterion-production/product_images/185/343_box_348x490.jpg' ''' data = { "url": get_url(id) } try: html = read_url(data["url"], timeout=timeout, unicode=True) except: html = ox.cache.read_url(data["url"], timeout=timeout) data["number"] = find_re(html, "
(.*?)
")) result = find_re(html, "