[fix] skip non-string result url/title/content

This commit is contained in:
Adam Tauber 2017-12-01 20:44:31 +01:00
parent 43855a0897
commit a065fcdcc9
1 changed files with 6 additions and 0 deletions

View File

@ -170,10 +170,16 @@ class ResultContainer(object):
self.paging = True self.paging = True
for i, result in enumerate(results): for i, result in enumerate(results):
if 'url' in result and not isinstance(result['url'], basestring):
continue
try: try:
result['url'] = result['url'].decode('utf-8') result['url'] = result['url'].decode('utf-8')
except: except:
pass pass
if 'title' in result and not isinstance(result['title'], basestring):
continue
if 'content' in result and not isinstance(result['content'], basestring):
continue
position = i + 1 position = i + 1
self._merge_result(result, position) self._merge_result(result, position)