All pastes #96339 Raw Edit

Stuff

public python v1 · immutable
#96339 ·published 2006-07-22 20:38 UTC
rendered paste body
import os,sys,re,urllibreg = 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('<a href="/title/(.*?)/.*?">(.*?)</a>(.*?)</li>')        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] = urlResults = IMDbSearch('space').SearchResultsprint Resultsclass 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="(.*?)"></a>')        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.CoverURLprint Cover.CoverSize