import os,sys,re,urllib reg = re.compile(r"&#[0-9]{1,3};") def fix(s): codes = reg.findall(s) for i in codes: s = s.replace(i,'%c'%(int(i.replace('&#','').replace(';','')))) return(s) class IMDbSearch: def __init__(self, find): self.SearchResults = {} sock = urllib.urlopen('http://www.imdb.com/find?s=tt&q=' + find) page = sock.read() sock.close() search = re.compile('(.*?)(.*?)') title = search.findall(page) if title != None: for a in title: b = "%s%s" % (a[1],a[2]) url = "http://www.imdb.com/title/%s/" % (a[0]) Title = fix(str(b)) self.SearchResults[Title] = url Results = IMDbSearch('space').SearchResults print Results class IMDbCover: def __init__(self,url): self.CoverURL = [] self.CoverSize = {} sock = urllib.urlopen(url) page = sock.read() sock.close() cover = re.compile('src="(http://.*?28m.jpg)" height="(.*?)" width="(.*?)">') image = cover.findall(page) if image != None: for a in image: self.CoverURL.append(a[0]) self.CoverSize[a[1]] = a[2] Cover = IMDbCover('http://www.imdb.com/title/tt0390221/') print Cover.CoverURL print Cover.CoverSize