forked from zaclys/searxng
[enh] standalone search example
This commit is contained in:
parent
6fb9eb8e47
commit
ea414c6574
36
utils/standalone_search.py
Normal file
36
utils/standalone_search.py
Normal file
@ -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)))
|
Loading…
Reference in New Issue
Block a user