@@ -22,6 +22,7 @@ answer_xpath = '//pod[attribute::primary="true"]/subpod/plaintext'
2222input_xpath = '//pod[starts-with(attribute::id, "Input")]/subpod/plaintext'
2323pods_xpath = '//pod'
2424subpods_xpath = './subpod'
25+pod_primary_xpath = './@primary'
2526pod_id_xpath = './@id'
2627pod_title_xpath = './@title'
2728plaintext_xpath = './plaintext'
@@ -78,10 +79,12 @@ def response(resp):
7879 infobox_title = None
7980
8081 pods = search_results.xpath(pods_xpath)
82+ result = ""
8183 result_chunks = []
8284 for pod in pods:
8385 pod_id = pod.xpath(pod_id_xpath)[0]
8486 pod_title = pod.xpath(pod_title_xpath)[0]
87+ pod_is_result = pod.xpath(pod_primary_xpath)
8588
8689 subpods = pod.xpath(subpods_xpath)
8790 if not subpods:
@@ -94,6 +97,9 @@ def response(resp):
9497
9598 if content and pod_id not in image_pods:
9699
100+ if pod_is_result:
101+ result = content
102+
97103 # if no input pod was found, title is first plaintext pod
98104 if not infobox_title:
99105 infobox_title = content
@@ -116,7 +122,7 @@ def response(resp):
116122
117123 # append link to site
118124 results.append({'url': resp.request.headers['Referer'].decode('utf8'),
119− 'title': 'Wolfram|Alpha',
120− 'content': infobox_title})
125+ 'title': infobox_title + ' - Wolfram|Alpha',
126+ 'content': result})
121127
122128 return results