# -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 import re import time from oxlib import stripTags, findRe from oxlib.cache import getUrlUnicode def getMovieData(allmovieId): html = getUrlUnicode("http://www.allmovie.com/cg/avg.dll?p=avg&sql=1:%s~T0" % allmovieId) data = {} data['poster'] = findRe(html, '.*?

(.*?)')) data['year'] = findRe(html, '(\d{4})') data['rating'] = findRe(html, '" alt="(\d+?) Stars"') data['country'] = findRe(html, '(.*?)(.*?)')).split(', ') data['genre'] = parseList(html, 'Genre / Type') data['keywords'] = parseList(html, 'Keywords') data['themes'] = parseList(html, 'Themes') html = getUrlUnicode("http://www.allmovie.com/cg/avg.dll?p=avg&sql=1:%s~T1" % allmovieId) data['review'] = stripTags(findRe(html, 'Review.*?

(.*?)')) return data def getMoviePoster(allmovieId): data = getMovieData(allmovieId) if data: return data['poster'] return '' def parseList(html, title): return map(lambda x: stripTags(x), findRe(html, '%s(.*?)' % title).split('

  • ')) if __name__ == '__main__': print getMovieData('177524')