From f24a6ae4e7452610add8f468848e15fd8695714e Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 27 Mar 2008 16:03:53 +0000 Subject: [PATCH] better little info but do not fail on imdbpro locked imdb pages --- scrapeit/imdb.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/scrapeit/imdb.py b/scrapeit/imdb.py index 1d16709..f01b976 100644 --- a/scrapeit/imdb.py +++ b/scrapeit/imdb.py @@ -8,7 +8,6 @@ import re, time import os import time -from elementtree.ElementTree import parse, tostring from BeautifulSoup import BeautifulSoup from google import google @@ -412,16 +411,18 @@ class IMDb: def parseReleaseinfo(self): soup = BeautifulSoup(self.getReleaseinfo()) - for row in soup('table',{'border': '0', 'cellpadding':'2'})[0]('tr'): - d = row('td', {'align':'right'}) - if d: - try: - possible_date = stripTags(str(d[0])).strip() - rdate = time.strptime(possible_date, "%d %B %Y") - rdate = time.strftime('%Y-%m-%d', rdate) - return rdate - except: - pass + info = soup('table',{'border': '0', 'cellpadding':'2'}) + if info: + for row in info[0]('tr'): + d = row('td', {'align':'right'}) + if d: + try: + possible_date = stripTags(str(d[0])).strip() + rdate = time.strptime(possible_date, "%d %B %Y") + rdate = time.strftime('%Y-%m-%d', rdate) + return rdate + except: + pass return None def getBusiness(self, forcereload = False):