All pastes #73270 Raw Edit

Anonymous

public python v1 · immutable
#73270 ·published 2006-06-27 17:36 UTC
rendered paste body
import os,sys,re,urllib#NZB_ = {'Details':[], 'Genre':[], 'Year':[], 'Tagline':[], 'Plot':[], 'Rating':[], 'Runtime':[], 'Actor':[], 'Alias':[]}def Title(url):    IMDb_ = {'Title':[]}    title = re.compile(r'<title>.*')    in_title = re.compile(r'<title>(.*?)</title>')    sock = urllib.urlopen(url)    page = sock.readlines()    sock.close()    for i in page:        if title.match(i) != None:            try:                IMDb_['Title'].append(in_title.search(i).group(1).strip())            except:                IMDb_['Title'].append('None')    return str(IMDb_['Title'])[2:-2]def Details(url):    IMDb_ = {'Details':[]}    details = re.compile(r'<p class="plotpar">.*')    in_details = re.compile(r'">(.*?)</p>')    sock = urllib.urlopen(url)    page = sock.readlines()    sock.close()    for i in page:        if details.match(i) != None:            try:                IMDb_['Details'].append(in_details.search(i).group(1).strip())            except:                IMDb_['Details'].append('None')    return str(IMDb_['Details'])[2:-2]def Genre(url):    IMDb_ = {'Genre':[]}    genres = re.compile(r'<a href="/Sections/Genres/.*')    in_genres = re.compile(r'<a href="/Sections/Genres/(.*?)/')    sock = urllib.urlopen(url)    page = sock.readlines()    sock.close()    for i in page:        if genres.match(i) != None:            try:                IMDb_['Genre'].append(in_genres.search(i).group(1).strip())            except:                IMDb_['Genre'].append('None')    return str(IMDb_['Genre'])[2:-2]def Year(url):    IMDb_ = {'Year':[]}    year = re.compile(r'.*<a href="/Sections/Years/.*')    in_year = re.compile(r'<a href="/Sections/Years/.*">(.*?)</a>')    sock = urllib.urlopen(url)    page = sock.readlines()    sock.close()    for i in page:        if year.match(i) != None:            try:                IMDb_['Year'].append(in_year.search(i).group(1).strip())            except:                IMDb_['Year'].append('None')    return str(IMDb_['Year'])[2:-2]def Tagline(url):    IMDb_ = {'Tagline':[]}    tagline = re.compile(r'<b class="ch">Tagline:</b>.*')    in_tagline = re.compile(r"</b>(.*)")    sock = urllib.urlopen(url)    page = sock.readlines()    sock.close()    for i in page:        if tagline.match(i) != None:            try:                IMDb_['Tagline'].append(in_tagline.search(i).group(1).strip())            except:                IMDb_['Tagline'].append('None')    return str(IMDb_['Tagline'])[2:-72]def Plot(url):    IMDb_ = {'Plot':[]}    plot = re.compile(r'<b class="ch">Plot Outline:</b>.*')    in_plot = re.compile(r"</b>(.*?)<a href")    sock = urllib.urlopen(url)    page = sock.readlines()    sock.close()    for i in page:        if plot.match(i) != None:            try:                IMDb_['Plot'].append(in_plot.search(i).group(1).strip())            except:                IMDb_['Plot'].append('None')    return str(IMDb_['Plot'])[2:-2]def Rating(url):    IMDb_ = {'Rating':[]}    rating = re.compile(r'<b>.*/.*</b>.*')    in_rating = re.compile(r"<b>(.*?)/.*</b> .*")    sock = urllib.urlopen(url)    page = sock.readlines()    sock.close()    for i in page:        if rating.match(i) != None:            try:                IMDb_['Rating'].append(in_rating.search(i).group(1).strip())            except:                IMDb_['Rating'].append('None')    return str(IMDb_['Rating'][0])def Runtime(url):    IMDb_ = {'Runtime':[]}    runtime = re.compile(r'(.*?) min')    in_runtime = re.compile(r"(.*?) min")    sock = urllib.urlopen(url)    page = sock.readlines()    sock.close()    for i in page:        if runtime.match(i) != None:            try:                IMDb_['Runtime'].append(in_runtime.search(i).group(1).strip())            except:                IMDb_['Runtime'].append('None')    return str(IMDb_['Runtime'][0]) + " min"def Writer(url):    NZB_Writer = []    sock = urllib.urlopen(url)    page = sock.read()    sock.close()    in_writer = re.compile('<br>\n.*/">(.*?)</a> \((.*?)\)<br>.*\n<br>')    writer = in_writer.findall(page)    NZB_Writer[0:50] = ""    for Writer in zip(writer):        try:            NZB_Writer.append(Writer[0])        except:            NZB_Writer.append('None')    return NZB_Writerdetail = Details("http://www.imdb.com/title/tt0317219/plotsummary")print detailgenre = Genre("http://www.imdb.com/title/tt0317219/")print genre#director = Director("http://www.imdb.com/title/tt0317219/")#print directorwriter = Writer("http://www.imdb.com/title/tt0317219/")print writeryear = Year("http://www.imdb.com/title/tt0317219/")print yeartagline = Tagline("http://www.imdb.com/title/tt0317219/")print taglineplot = Plot("http://www.imdb.com/title/tt0317219/")print plotrating = Rating("http://www.imdb.com/title/tt0317219/")print ratingruntime = Runtime("http://www.imdb.com/title/tt0317219/")print runtime