summaryrefslogtreecommitdiff
path: root/searx/engines/wolframalpha.py
diff options
context:
space:
mode:
authora01200356 <a01200356@itesm.mx>2015-12-23 00:01:00 -0600
committera01200356 <a01200356@itesm.mx>2015-12-23 00:01:00 -0600
commit4578575c284584a58cce0acd85f86bef2f49d77f (patch)
tree0eb5e147f4a4525d4e3a08d6b6c127d7d4d34e14 /searx/engines/wolframalpha.py
parent47b4a85fe33cfbb1c83556bdf3c3a6cdfdb178ab (diff)
Wolfie kinda works using API
Diffstat (limited to 'searx/engines/wolframalpha.py')
-rw-r--r--searx/engines/wolframalpha.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/searx/engines/wolframalpha.py b/searx/engines/wolframalpha.py
new file mode 100644
index 000000000..be467681f
--- /dev/null
+++ b/searx/engines/wolframalpha.py
@@ -0,0 +1,60 @@
+"""
+ WolframAlpha
+
+ @website http://www.wolframalpha.com/
+
+ @using-api yes
+ @results no c
+ @stable i guess so
+ @parse result
+"""
+
+import wolframalpha
+
+# engine dependent config
+paging = False
+
+# search-url
+# url = 'http://www.wolframalpha.com/'
+# search_url = url+'input/?{query}'
+
+client_id = '5952JX-X52L3VKWT8'
+'''
+# do search-request
+def request(query, params):
+ params['url'] = search_url.format(query=urlencode({'i': query}))
+ print params
+
+ return params
+
+
+# get response from search-request
+def response(resp):
+ print resp
+
+ dom = html.fromstring(resp.text)
+ #resshit = dom.find_class('output pnt')
+ #for shit in resshit:
+ #print shit.text_content()
+ results = []
+ #results.append({'url': 'https://wikipedia.org', 'title': 'Wolfie, lol', 'content': 'es kwatro'})
+ #print results
+ #return results
+
+ # parse results
+ for result in dom.xpath(results_xpath):
+ print result
+
+ link = result.xpath(link_xpath)[0]
+ href = urljoin(url, link.attrib.get('href'))
+ title = escape(extract_text(link))
+ content = escape(extract_text(result.xpath(content_xpath)))
+
+ # append result
+ results.append({'url': href,
+ 'title': title,
+ 'content': content})
+
+ print results
+ return results
+'''