1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-16 17:40:11 +01:00
searxng/searxng_extra/google_search.py

38 lines
923 B
Python
Raw Normal View History

# SPDX-License-Identifier: AGPL-3.0-or-later
2014-07-21 18:07:04 +02:00
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['pageno'] = 1
request_params['language'] = 'en_us'
2017-01-03 19:15:55 +01:00
request_params['time_range'] = ''
2014-07-21 18:07:04 +02:00
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)
2017-01-03 19:15:55 +01:00
resp.search_params = request_params
2014-07-21 18:07:04 +02:00
print(dumps(google.response(resp)))