diff options
| author | Adam Tauber <asciimoo@gmail.com> | 2016-07-26 00:06:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-26 00:06:16 +0200 |
| commit | 7d9c898170df497036b8a7a70a1a5c86c3859670 (patch) | |
| tree | ca1722a5d0d1bc8493e50bd334a07ea50e744e63 /searx/engines/google.py | |
| parent | 54d987636e4b03d19a99ad9d143bf63b119af208 (diff) | |
| parent | 90e74fbb288b2f1df0516d877d3bd239c7800412 (diff) | |
Merge pull request #634 from kvch/advanced-search
support time range search
Diffstat (limited to 'searx/engines/google.py')
| -rw-r--r-- | searx/engines/google.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/searx/engines/google.py b/searx/engines/google.py index fd5e7b54c..3b845cbcd 100644 --- a/searx/engines/google.py +++ b/searx/engines/google.py @@ -24,6 +24,7 @@ categories = ['general'] paging = True language_support = True use_locale_domain = True +time_range_support = True # based on https://en.wikipedia.org/wiki/List_of_Google_domains and tests default_hostname = 'www.google.com' @@ -92,6 +93,11 @@ search_url = ('https://{hostname}' + search_path + '?{query}&start={offset}&gws_rd=cr&gbv=1&lr={lang}&ei=x') +time_range_search = "&tbs=qdr:{range}" +time_range_dict = {'day': 'd', + 'week': 'w', + 'month': 'm'} + # other URLs map_hostname_start = 'maps.google.' maps_path = '/maps' @@ -179,6 +185,8 @@ def request(query, params): query=urlencode({'q': query}), hostname=google_hostname, lang=url_lang) + if params['time_range']: + params['url'] += time_range_search.format(range=time_range_dict[params['time_range']]) params['headers']['Accept-Language'] = language params['headers']['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' |