aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-01-20 18:01:56 +0100
committerneodarz <neodarz@neodarz.net>2019-01-20 18:01:56 +0100
commit0001a7a57d9f9a5d3e7e0925e0b38642593240b4 (patch)
treedf8464346f46ed5b120ba4277fcec5bf9d5e0642 /src
parentc4f89d79f22d0e44b025cb2785ea8fd322c0fe43 (diff)
downloadryzomcore_searx-0001a7a57d9f9a5d3e7e0925e0b38642593240b4.tar.xz
ryzomcore_searx-0001a7a57d9f9a5d3e7e0925e0b38642593240b4.zip
Fix crash when parsing plein text result
Diffstat (limited to 'src')
-rw-r--r--src/khaganatWikhan.py27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/khaganatWikhan.py b/src/khaganatWikhan.py
index 083696c..988ee5a 100644
--- a/src/khaganatWikhan.py
+++ b/src/khaganatWikhan.py
@@ -43,26 +43,22 @@ def response(resp):
doc = fromstring(resp.text)
- # parse results
- # Quickhits
+ # Page result
for r in doc.xpath('//div[@class="search_quickresult"]/ul/li'):
try:
res_url = r.xpath('.//a[@class="wikilink1"]/@href')[-1]
- except:
- continue
-
- if not res_url:
- continue
+ title = extract_text(r.xpath('.//a[@class="wikilink1"]/@title'))
- title = extract_text(r.xpath('.//a[@class="wikilink1"]/@title'))
+ # append result
+ results.append({'title': title,
+ 'content': "Page "+title,
+ 'url': base_url + res_url})
- # append result
- results.append({'title': title,
- 'content': "",
- 'url': base_url + res_url})
+ except:
+ continue
- # Search results
- for r in doc.xpath('//dl[@class="search_results"]/*'):
+ # Plein text results
+ for r in doc.xpath('//div[@class="search_fullpage_result"]/*'):
try:
if r.tag == "dt":
res_url = r.xpath('.//a[@class="wikilink1"]/@href')[-1]
@@ -77,8 +73,5 @@ def response(resp):
except:
continue
- if not res_url:
- continue
-
# return results
return results