dont fail if no results are returned

This commit is contained in:
j 2008-11-04 17:05:44 +01:00
parent d523862c9d
commit 6892909b3b

View file

@ -85,9 +85,10 @@ def find(query, max_results=10):
data = getUrl(url, timeout=0)
result = simplejson.loads(data)
results = []
for r in result['query']['search']:
title = r['title']
url = "http://en.wikipedia.org/wiki/%s" % title.replace(' ', '_')
results.append((title, url, ''))
if result:
for r in result['query']['search']:
title = r['title']
url = "http://en.wikipedia.org/wiki/%s" % title.replace(' ', '_')
results.append((title, url, ''))
return results