do not fail if no edit link on wikipedia
This commit is contained in:
parent
63cf69d05f
commit
9616b3477e
|
@ -26,7 +26,9 @@ def searchByImdb(imdb_id, title=None, director=None):
|
||||||
data = read_url(url)
|
data = read_url(url)
|
||||||
soup = BeautifulSoup(data)
|
soup = BeautifulSoup(data)
|
||||||
edit_url = soup('a', dict(href=re.compile('action=edit'),
|
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('&', '&')
|
edit_url = "http://en.wikipedia.org%s" % edit_url.replace('&', '&')
|
||||||
data = read_url(edit_url)
|
data = read_url(edit_url)
|
||||||
w_imdb_id = data.find('imdb_id')
|
w_imdb_id = data.find('imdb_id')
|
||||||
|
|
Loading…
Reference in New Issue