All pastes #57033 Raw Edit

Something

public python v1 · immutable
#57033 ·published 2006-05-19 06:21 UTC
rendered paste body
import urllib, urllib2import re, os, sysfrom string import split, replace, findimdb_Detail = []imdb_Director = []imdb_Writer = []imdb_Genre = []imdb_Details = urllib.urlopen("http://www.imdb.com/title/tt0076759/plotsummary")imdb_Info = urllib.urlopen("http://www.imdb.com/title/tt0076759/")imdb_HTML1 = imdb_Details.read()imdb_HTML2 = imdb_Info.read()imdb_Details.close()imdb_Info.close()imdb_re_Details = re.compile('<p class="plotpar">(.*)</p>')imdb_re_Director = re.compile('Directed by</b><br>\n<a href="/name/nm(.*)/">(.*)</a><br>')imdb_re_Writer = re.compile('Writing credits</b>\n\n<br>\n<a href="/name/nm(.*)/">(.*)</a>')imdb_re_Genre = re.compile('<a href="/Sections/Genres/(.*)/">')imdb_List1 = imdb_re_Details.findall(imdb_HTML1)imdb_List2 = imdb_re_Director.findall(imdb_HTML2)imdb_List3 = imdb_re_Writer.findall(imdb_HTML2)imdb_List4 = imdb_re_Genre.findall(imdb_HTML2)imdb_Detail[0:50] = ""imdb_Director[0:50] = ""imdb_Writer[0:50] = ""imdb_Genre[] = ""for a,b,c,d in zip(imdb_List1,imdb_List2,imdb_List3,imdb_List4):    Director = 'Director:      %s' % (b[1])    Writer =   'Writer:         %s' % (c[1])    Genre =    'Genre:          %s' % (d)    imdb_Detail.append(a)    imdb_Director.append(Director)    imdb_Writer.append(Writer)    imdb_Genre.append(Genre)""" An HTML Genre sample for recompiling on line 21: """#   <a href="/Sections/Genres/Action/">Action</a> / <a href="/Sections/Genres/Adventure/">Adventure</a> / <a href="/Sections/Genres/Fantasy/">Fantasy</a> / <a href="/Sections/Genres/Sci-Fi/">Sci-Fi</a> <a href="/rg/title-tease/keywords/title/tt0076759/keywords">(more)</a>""" The script as-is prints the imdb_Genre entry like the line below when executed. I'm poor with regexp and     I'm not sure why line 21 does not recompile the entries for imdb_Genre like ["Action","Adventure","Fantasy","Sci-Fi"]: """#   ['Genre:          Action/">Action</a> / <a href="/Sections/Genres/Adventure/">Adventure</a> / <a href="/Sections/Genres/Fantasy/">Fantasy</a> / <a href="/Sections/Genres/Sci-Fi']""" I need imdb_Genre to recompile all of the  "Sections/Genres/(.*)/"  and have those entries print a line     like the example below. This bit will be used to grab info from imbd for other movies so this line will     not always have the same genres, or amount of genres. """#   Action / Adventure / Fantasy / Sci-Fiprint imdb_Detailprint imdb_Directorprint imdb_Writerprint imdb_Genre