jung/tools/sx.sh

15 lines
501 B
Bash
Executable file

#!/bin/bash
# SearXNG search helper: usage: ./sx.sh "query" [limit]
q="$1"; lim="${2:-8}"
curl -s --max-time 30 "http://localhost:8888/search" \
--data-urlencode "q=$q" --data-urlencode "format=json" --data-urlencode "language=ru" \
| python3 -c "
import json,sys
d=json.load(sys.stdin)
for i,r in enumerate(d.get('results',[])[:$lim],1):
print(f'{i}. {r[\"title\"]}')
print(f' {r[\"url\"]}')
c=r.get('content','').replace(chr(10),' ')
if c: print(f' {c[:220]}')
print()
"