75 search_results = etree.XML(resp.content)
78 if search_results.xpath(failure_xpath):
82 infobox_title = search_results.xpath(input_xpath)[0].text
86 pods = search_results.xpath(pods_xpath)
90 pod_id = pod.xpath(pod_id_xpath)[0]
91 pod_title = pod.xpath(pod_title_xpath)[0]
92 pod_is_result = pod.xpath(pod_primary_xpath)
94 subpods = pod.xpath(subpods_xpath)
99 for subpod
in subpods:
100 content = subpod.xpath(plaintext_xpath)[0].text
101 image = subpod.xpath(image_xpath)
103 if content
and pod_id
not in image_pods:
105 if pod_is_result
or not result_content:
106 if pod_id !=
"Input":
107 result_content =
"%s: %s" % (pod_title, content)
110 if not infobox_title:
111 infobox_title = content
114 result_chunks.append({
'label': pod_title,
'value': content})
117 result_chunks.append(
120 'image': {
'src': image[0].xpath(img_src_xpath)[0],
'alt': image[0].xpath(img_alt_xpath)[0]},
124 if not result_chunks:
127 title =
"Wolfram Alpha (%s)" % infobox_title
132 'infobox': infobox_title,
133 'attributes': result_chunks,
134 'urls': [{
'title':
'Wolfram|Alpha',
'url': resp.request.headers[
'Referer']}],
139 results.append({
'url': resp.request.headers[
'Referer'],
'title': title,
'content': result_content})