diff options
author | Adam Tauber <asciimoo@gmail.com> | 2014-07-21 18:07:04 +0200 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2014-07-21 18:07:04 +0200 |
commit | ea414c65745b69695f89c923f46a77553a3303fe (patch) | |
tree | 2c2a31d0b160ce714ad0eacb1e11c4af673c6cc0 /utils | |
parent | 6fb9eb8e470c31f2a6a3d5fb5f91606479d5ef26 (diff) | |
download | searxng-ea414c65745b69695f89c923f46a77553a3303fe.tar.gz searxng-ea414c65745b69695f89c923f46a77553a3303fe.zip |
[enh] standalone search example
Diffstat (limited to 'utils')
-rw-r--r-- | utils/standalone_search.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/utils/standalone_search.py b/utils/standalone_search.py new file mode 100644 index 000000000..7e9516f82 --- /dev/null +++ b/utils/standalone_search.py @@ -0,0 +1,36 @@ +from sys import argv, exit + +if not len(argv) > 1: + print('search query required') + exit(1) + +import requests +from json import dumps +from searx.engines import google +from searx.search import default_request_params + +request_params = default_request_params() +# Possible params +# request_params['headers']['User-Agent'] = '' +# request_params['category'] = '' +# request_params['started'] = '' + +request_params['pageno'] = 1 +request_params['language'] = 'en_us' + +params = google.request(argv[1], request_params) + +request_args = dict( + headers=request_params['headers'], + cookies=request_params['cookies'], +) + +if request_params['method'] == 'GET': + req = requests.get +else: + req = requests.post + request_args['data'] = request_params['data'] + +resp = req(request_params['url'], **request_args) + +print(dumps(google.response(resp))) |