All pastes #169639 Raw Edit

Something

public python v1 · immutable
·published 2006-09-14 01:51 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 replaceOne(args):    return (args * 1) + (args == 0)class IMDb:    def __init__(self, url, Info=False, Details=False, Gallery=False):        if Info == True:            fromInfo         = urllib.urlopen(url).read()            self.fromInfo    = fix(fromInfo).replace(' / ','').replace('</a> <i>',' ').replace('</i>','</a>')        if Details == True:                self.fromDetails = urllib.urlopen(url + 'plotsummary').read()        if Gallery == True:            self.fromGallery = urllib.urlopen(url + 'photogallery').read()def Galleries(fromGallery, page='0'):    in_gallery = re.compile('"(photogallery.*?|/gallery/.*?)"><img src="(.*?jpg)"')    in_pgLeft  = re.compile('There are.*?>(.*?) more</a>')        Gallery   = []    GalInfo   = []    imgLeft   = []    pgLeft    = []    for a in in_gallery.findall(fromGallery):        Gallery.append(a[0])        imgLeft.append(urllib.urlopen(url + a[0]).read())    for a in imgLeft:        pgLeft.append(in_pgLeft.findall(a))    for a in pgLeft:        GalInfo.append(int(str(a)[2:-2]) / 12)    for cnt, item in enumerate(GalInfo): GalInfo[cnt] = (item * 1) + (item == 0)    #for cnt in range(0,25,12):        #Links = Gallery[0][:Gallery[0].rfind('-')] + str(int(Gallery[0][Gallery[0].rfind('-') + 1:]) + 12)    Links = []        for b in GalInfo:        for cnt in range(0,int(b*12+1),12):            for a in Gallery:                Links.append(url + a[:-1] + str(cnt))    print Links                #print thumbs[1]    #for a in pgleft:    #    pgLeft = int(a) / 12    #if '0' in pgLeft:    #    pgLeft.replace('0','1')    #print pgLeft            #for a in Gallery:    #    thumbs = urllib.urlopen(url + a).read()            #gallery = in_gallery.findall(thumbs)                      # find thumbs for 1st Gallery page of each Gallery    #for a in gallery:    #    Thumbs.append(a[1].replace('th-',''))                 # changes Thumb images to full-size Images    #pgleft  = in_pgLeft.findall(thumbs)                       # parse how many thumbs are left    #for a in pgleft:    #    pgLeft = int(a) / 12                                  # how many pages are in each gallery    #return Gallery, Thumbsnum = '0'url = 'http://www.imdb.com/title/tt0315824/'imdb = IMDb(url, Gallery=True)gal = Galleries(imdb.fromGallery, page=num)#print gal#print thumb