ddg (619B)
1 #!/bin/sh 2 3 if [ $# -lt 1 ]; 4 then 5 printf "usage: %s search terms ...\n" "$(basename "$0")" >&2 6 exit 1 7 fi 8 9 [ -z "$PAGER" -o ! -t 1 ] && PAGER="cat" 10 11 search="$(printf "%s" "$*" \ 12 | perl -p -e 's/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg')" 13 14 curl -s --user-agent \ 15 "Lynx/2.8.8dev.3 libwww-FM/2.14 SSL-MM/1.4.1" \ 16 --data "q=${search}&kp=-1&kl=us-en" \ 17 "https://duckduckgo.com/html/" \ 18 | xpath -a href "//a[@href]" \ 19 | grep "^.*://" \ 20 | grep -v "https://duckduckgo.com" \ 21 | grep -v "http://r.duckduckgo.com" \ 22 | grep -v "http://ad.ddg.gg" \ 23 | grep -v ".r.msn.com" \ 24 | grep -v "^$" \ 25 | uniq \ 26 | head -n -7 27