@@ -22,6 +22,7 @@ answer_xpath = '//pod[attribute::primary="true"]/subpod/plaintext'
22input_xpath = '//pod[starts-with(attribute::id, "Input")]/subpod/plaintext'
22input_xpath = '//pod[starts-with(attribute::id, "Input")]/subpod/plaintext'
23pods_xpath = '//pod'
23pods_xpath = '//pod'
24subpods_xpath = './subpod'
24subpods_xpath = './subpod'
25+pod_primary_xpath = './@primary'
25pod_id_xpath = './@id'
26pod_id_xpath = './@id'
26pod_title_xpath = './@title'
27pod_title_xpath = './@title'
27plaintext_xpath = './plaintext'
28plaintext_xpath = './plaintext'
@@ -78,10 +79,12 @@ def response(resp):
78 infobox_title = None
79 infobox_title = None
80 pods = search_results.xpath(pods_xpath)
81 pods = search_results.xpath(pods_xpath)
81 result_chunks = []
83 result_chunks = []
82 for pod in pods:
84 for pod in pods:
83 pod_id = pod.xpath(pod_id_xpath)[0]
85 pod_id = pod.xpath(pod_id_xpath)[0]
84 pod_title = pod.xpath(pod_title_xpath)[0]
86 pod_title = pod.xpath(pod_title_xpath)[0]
87+ pod_is_result = pod.xpath(pod_primary_xpath)
86 subpods = pod.xpath(subpods_xpath)
89 subpods = pod.xpath(subpods_xpath)
87 if not subpods:
90 if not subpods:
@@ -94,6 +97,9 @@ def response(resp):
95 if content and pod_id not in image_pods:
98 if content and pod_id not in image_pods:
97 # if no input pod was found, title is first plaintext pod
103 # if no input pod was found, title is first plaintext pod
98 if not infobox_title:
104 if not infobox_title:
99 infobox_title = content
105 infobox_title = content
@@ -116,7 +122,7 @@ def response(resp):
117 # append link to site
123 # append link to site
118 results.append({'url': resp.request.headers['Referer'].decode('utf8'),
124 results.append({'url': resp.request.headers['Referer'].decode('utf8'),
119− 'title': 'Wolfram|Alpha',
125+ 'title': infobox_title + ' - Wolfram|Alpha',
120− 'content': infobox_title})
126+ 'content': result})
122 return results
128 return results