1234567891011121314151617181920212223242526272829303132333435
  1. from sys import argv, exit
  2. if not len(argv) > 1:
  3. print('search query required')
  4. exit(1)
  5. import requests
  6. from json import dumps
  7. from searx.engines import google
  8. from searx.search import default_request_params
  9. request_params = default_request_params()
  10. # Possible params
  11. # request_params['headers']['User-Agent'] = ''
  12. # request_params['category'] = ''
  13. request_params['pageno'] = 1
  14. request_params['language'] = 'en_us'
  15. request_params['time_range'] = ''
  16. params = google.request(argv[1], request_params)
  17. request_args = dict(
  18. headers=request_params['headers'],
  19. cookies=request_params['cookies'],
  20. )
  21. if request_params['method'] == 'GET':
  22. req = requests.get
  23. else:
  24. req = requests.post
  25. request_args['data'] = request_params['data']
  26. resp = req(request_params['url'], **request_args)
  27. resp.search_params = request_params
  28. print(dumps(google.response(resp)))