summaryrefslogtreecommitdiff
path: root/searx/engines/wolframalpha.py
blob: be467681f2cba9b3df4efa30b81585929ec8495a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
'''