All pastes #176930 Raw Edit

Something

public python v1 · immutable
#176930 ·published 2006-09-20 01:43 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(';',''))))    return(s)def Search(search):    search = search.strip().translate(string.maketrans('',''),'~!@#$%^&*()_+`-={}|[]\:";\'<>?,./').replace(' ','+')    in_src = re.compile('0" href="(.*?)\?.*?">(.*?)<')    source = urllib.urlopen('http://www.tv.com/search.php?type=11&stype=program&qs=' + search + '&tag=filter;tv_shows').read()        Titles = []    Links  = []        info = in_src.findall(source)    for a in info:        Titles.append(a[1])        Links.append(a[0] + '?full_summary=1&tag=showspace_links;full_summary')    return Titles, Linksclass Info:    def __init__(self, url, Info=False):        if Info == True:            fromInfo      = urllib.urlopen(url).read()            self.fromInfo = fix(fromInfo)def Title(fromInfo):    in_title = re.compile('>(.*?)</h1> ')    return in_title.findall(fromInfo)def Cover(fromInfo):    in_cover = re.compile('="(.*?)" alt="(.*?)" />  ')    for a in in_cover.findall(fromInfo): return a[0]def Airs(fromInfo):    in_airs = re.compile('t: .*?>(.*?)<')    return in_airs.findall(fromInfo)def Status(fromInfo):    in_status = re.compile('us:\n.*\n(.*)')    for a in in_status.findall(fromInfo): return [str(a).strip()]def Premiered(fromInfo):    in_prem = re.compile('ered:\n.*\n(.*)')    for a in in_prem.findall(fromInfo): return [str(a).strip()]def LastAired(fromInfo):    in_last = re.compile(' Aired:.*\n.*\n(.*)')    for a in in_last.findall(fromInfo): return [str(a).strip()]def Genres(fromInfo):    in_genre = re.compile('".*?nre">(.*?)<')    return in_genre.findall(fromInfo)def Rating(fromInfo):    in_rating = re.compile('8">(.*?)</s')    in_votes  = re.compile('"f-11">(.*?)</span>\n.*?</d')    for a, b in zip(in_rating.findall(fromInfo), in_votes.findall(fromInfo)): Ratings = ['%s (%s)' % (a,b)]    return Ratingsdef LastEpisode(fromInfo): #!!!!!!    in_lastep = re.compile('de:.*?>(.*?)</.*\n(.*?)<')    for a in in_lastep.findall(fromInfo):        return [str(a[0]).strip()], [str(a[1]).strip()]def rDetails(fromInfo): #!!!!!!    in_rDetails = re.compile('>"(.*?)"</.*?/>(.*?)<')    rDetails = []    for a in in_rDetails.findall(fromInfo):        join = '%s:\n%s' % (a[0].strip(), a[1].strip())        rDetails.append(join)    return rDetailsdef rRatings(fromInfo):    in_review = re.compile('re">(.*?)</sp')    return in_review.findall(fromInfo)def Details(fromInfo): #!!!!!!    in_details = re.compile('div class="mt-10">(.*?)</div>', re.DOTALL)    #in_details = re.compile('>*\n(.*?)<br />.*\n<br />')    Details = []    for a in in_details.findall(fromInfo):        Details.append(str(a).strip().replace('<b>','').replace('</b>','').replace('<i>','(').replace('</i>',')').replace('<br />','').replace('((','(').replace('))',')'))    return DetailsTitles, Links = Search('family')selection = 6#print Titles[selection]#print Links[selection]tv = Info(Links[selection], Info=True)#print Title(tv.fromInfo)#print Cover(tv.fromInfo)#print Airs(tv.fromInfo)#print Status(tv.fromInfo)#print Premiered(tv.fromInfo)#print LastAired(tv.fromInfo)#print Genres(tv.fromInfo)#print Rating(tv.fromInfo)print rDetails(tv.fromInfo)print rRatings(tv.fromInfo)try:    LTitle, LDetails = LastEpisode(tv.fromInfo)    print LTitle    print LDetailsexcept:    print "Last Episode Not Available"#print Details(tv.fromInfo)