All pastes #165329 Raw Edit

Someone

public python v1 · immutable
·published 2006-09-09 19:26 UTC
rendered paste body
import os,sys,re,urllib,stringreg = 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(';','')))).replace('<em>','').replace('</em>','').replace('<br>','')    return(s)def IMDbFunc(url):    sock      = urllib.urlopen(url)    fromInfo      = sock.read()    sock.close()    fromInfo = fromInfo.replace(' / ','').replace('</a> <i>',' ').replace('</i>','</a>').replace('\n\n<br>\n','')    sock      = urllib.urlopen(url + 'plotsummary')    fromDetails   = sock.read()    sock.close()    return fromInfo, fromDetailsfromInfo, fromDetails = IMDbFunc('http://www.imdb.com/title/tt0315824/')def Title(fromInfo):    # Movie's Title fromInfo saved into a list    in_title         = re.compile('<title>(.*)<.*?')    Title            = in_title.findall(fromInfo)    return Titleprint Title(fromInfo)def Year(fromInfo):    # Movie's Year fromInfo saved into a list    in_year          = re.compile('/Sections/Years/([0-9]*)')    Year             = in_year.findall(fromInfo)    return Yearprint Year(fromInfo)def Directors(fromInfo):    # Movie's Directors fromInfo saved into a list    in_directors     = re.compile('.*?Directed by.*\n(.*)')    get_directors    = str(in_directors.findall(fromInfo))    from_directors   = re.compile('<a [^>]*>([^<]*)</a>')    Directors        = from_directors.findall(get_directors)    return Directorsprint Directors(fromInfo)def MPAA(fromInfo):    #Movie's MPAA Rating fromInfo saved into a list    in_mpaa          = re.compile('MPAA</a>:</b>([^<]*)<')    MPAA             = in_mpaa.findall(fromInfo)    return MPAAprint MPAA(fromInfo)def Tagline(fromInfo):    # Movie's Tagline fromInfo saved into a list    in_tagline       = re.compile('Tagline:</b>([^<]*)<')    tagline          = in_tagline.findall(fromInfo)    Tagline = []    for a in tagline:        Tagline.append(a.strip())    return Taglineprint Tagline(fromInfo)def Runtime(fromInfo):    # Movie's Runtime fromInfo saved into a list    in_runtime       = re.compile('Runtime:</b>([^<]*)<')    runtime          = in_runtime.findall(fromInfo)    Runtime = []    for a in runtime:        Runtime.append(runtime[0].replace('\n','').strip())    return Runtimeprint Runtime(fromInfo)    def CoverURL(fromInfo):    # Movie's Cover Image URL fromInfo saved into a list    in_cover         = re.compile('.*?(http://.*?m.jpg)".*')    CoverURL         = in_cover.findall(fromInfo)    return CoverURLprint CoverURL(fromInfo)def Writers(fromInfo):    # Movie's Writers saved into a list    in_writers       = re.compile('ts</b>\n.*\n.*\n(.*)\n')    get_writers      = str(in_writers.findall(fromInfo))    from_writers     = re.compile('<a href=\"/name/[^>]*>([^<]*)<')    Writers          = from_writers.findall(get_writers)    return Writersprint Writers(fromInfo)    def Rating(fromInfo):    # Movie's IMDb Rating fromInfo saved into a list    in_rating        = re.compile('<b>(.*?)</b> (.*)')    rating           = in_rating.findall(fromInfo)    Rating = []    for a in rating:        Rating.append('%s %s' % (a[0],a[1]))    return Ratingprint Rating(fromInfo)def Genres(fromInfo):    in_genres        = re.compile('Genres/(.*?)/')    Genres           = in_genres.findall(fromInfo)    return Genresprint Genres(fromInfo)def Details(fromDetails):    in_details       = re.compile('<p class="plotpar">(.*?)</p>')    Details          = in_details.findall(fromDetails)    return Detailsprint Details(fromDetails)def Plot(fromInfo):    in_plot          = re.compile('Plot Outline:</b>([^<]*)<')    Plot             = in_plot.findall(fromInfo)    return Plotprint Plot(fromInfo)def Cast(fromInfo):    # Movie's Actor & Alias names saved in separate lists    in_cast          = re.compile('<td valign=\"middle\"><a href[^>]*>([^<]*)</a></td><td valign=\"middle\" nowrap=\"1\">[. ]*</td><td valign=\"middle\">([^<]*)</td></tr>')    Cast             = in_cast.findall(fromInfo)    CastActor = []    CastAlias = []    for a in Cast:        CastActor.append(a[0])        CastAlias.append(a[1])    return CastActor, CastAliasprint Cast(fromInfo)def Countries(fromInfo):    in_countries     = re.compile('ries/(.*?)/')    Countries        = in_countries.findall(fromInfo)    return Countriesprint Countries(fromInfo)def Languages(fromInfo):    in_languages    = re.compile('uages/(.*?)/')    Languages       = in_languages.findall(fromInfo)    return Languagesprint Languages(fromInfo)    def Color(fromInfo):    in_color        = re.compile('o=.*?">(.*?)<')    Color           = in_color.findall(fromInfo)    return Colorprint Color(fromInfo)def SoundMix(fromInfo):    in_sound        = re.compile('x=.*?">(.*?)</a>')    Sound           = in_sound.findall(fromInfo)    return Soundprint SoundMix(fromInfo)def Certificates(fromInfo):    in_cert         = re.compile('tes=.*?">(.*?)<')    Cert            = in_cert.findall(fromInfo)    return Certprint Certificates(fromInfo)