jung/tools/cogito.sh

18 lines
765 B
Bash
Executable file

#!/bin/bash
# cogito-shop search: ./cogito.sh "query"
UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
q=$(python3 -c "import urllib.parse,sys;print(urllib.parse.quote(sys.argv[1]))" "$1")
curl -sL --max-time 30 -H "User-Agent: $UA" "https://cogito-shop.com/search/?q=$q" | python3 -c "
import re,sys
h = sys.stdin.read()
if 'ничего не найдено' in re.sub(r'<[^>]+>','',h):
print('(nothing found)')
seen=set()
for m in re.finditer(r'alt=\"([^\"]{8,140})\"', h):
t = m.group(1)
if t in seen or t in ('Telegram','YouTube','Top.Mail.Ru'): continue
seen.add(t)
print(' -', t)
for m in re.finditer(r'href=\"(/person/[^\"]+)\"', h):
print(' PERSON:', m.group(1))
"