aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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