do not fail if no edit link on wikipedia

This commit is contained in:
j 2007-09-16 18:33:08 +00:00
parent 63cf69d05f
commit 9616b3477e
1 changed files with 9 additions and 7 deletions

View File

@ -26,7 +26,9 @@ def searchByImdb(imdb_id, title=None, director=None):
data = read_url(url)
soup = BeautifulSoup(data)
edit_url = soup('a', dict(href=re.compile('action=edit'),
title=re.compile('You can edit this page.')))[0]['href']
title=re.compile('You can edit this page.')))
if edit_url:
edit_url = edit_url[0]['href']
edit_url = "http://en.wikipedia.org%s" % edit_url.replace('&', '&')
data = read_url(edit_url)
w_imdb_id = data.find('imdb_id')