sweb

Some web helper scripts.
git clone git://r-36.net/sweb
Log | Files | Refs | LICENSE

google (498B)


      1 #!/bin/sh
      2 
      3 if [ $# -lt 1 ];
      4 then
      5 	echo "usage: `basename $0` search terms ..."
      6 	echo "Beware, that Google could filter the User-Agent!" \
      7 		"Be prepared to change it!"
      8 	exit 1
      9 fi
     10 
     11 search=`echo -n "$*" \
     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 	"https://encrypted.google.com/search?safe=off&q=${search}" \
     17 	| xpath -a href "//a[@href]" \
     18 	| grep "^/url" \
     19 	| sed 's,/url?q=,,' \
     20 	| sed 's,&sa=U.*,,'
     21