diff options
author | asciimoo <asciimoo@gmail.com> | 2014-01-31 05:10:49 +0100 |
---|---|---|
committer | asciimoo <asciimoo@gmail.com> | 2014-01-31 05:10:49 +0100 |
commit | 68a08325241478df8374a8dd640d74648bdc4b72 (patch) | |
tree | a2725e8f0a83d4d7b35c78519b968a9d79675409 /searx/engines/startpage.py | |
parent | 2a788c8f29f63bc069436f1a12343a47d66f2523 (diff) | |
download | searxng-68a08325241478df8374a8dd640d74648bdc4b72.tar.gz searxng-68a08325241478df8374a8dd640d74648bdc4b72.zip |
[enh] search language support upadtes
Diffstat (limited to 'searx/engines/startpage.py')
-rw-r--r-- | searx/engines/startpage.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/searx/engines/startpage.py b/searx/engines/startpage.py index ab331a0ba..fcfc21160 100644 --- a/searx/engines/startpage.py +++ b/searx/engines/startpage.py @@ -6,20 +6,25 @@ search_url = None # TODO paging paging = False +# TODO complete list of country mapping +country_map = {'en_US': 'eng', + 'en_UK': 'uk', + 'nl_NL': 'ned'} def request(query, params): - global search_url query = urlencode({'q': query})[2:] params['url'] = search_url params['method'] = 'POST' params['data'] = {'query': query, 'startat': (params['pageno'] - 1) * 10} # offset + country = country_map.get(params['language'], 'eng') + params['cookies']['preferences'] = \ + 'lang_homepageEEEs/air/{country}/N1NsslEEE1N1Nfont_sizeEEEmediumN1Nrecent_results_filterEEE1N1Nlanguage_uiEEEenglishN1Ndisable_open_in_new_windowEEE0N1Ncolor_schemeEEEnewN1Nnum_of_resultsEEE10N1N'.format(country=country) # noqa return params def response(resp): - global base_url results = [] dom = html.fromstring(resp.content) # ads xpath //div[@id="results"]/div[@id="sponsored"]//div[@class="result"] |