summaryrefslogtreecommitdiff
path: root/src/usr.bin/nc/scripts/alta
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr.bin/nc/scripts/alta')
-rw-r--r--src/usr.bin/nc/scripts/alta33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/usr.bin/nc/scripts/alta b/src/usr.bin/nc/scripts/alta
new file mode 100644
index 0000000000..7a091767e8
--- /dev/null
+++ b/src/usr.bin/nc/scripts/alta
@@ -0,0 +1,33 @@
1#! /bin/sh
2## special handler for altavista, since they only hand out chunks of 10 at
3## a time. Tries to isolate out results without the leading/trailing trash.
4## multiword arguments are foo+bar, as usual.
5## Second optional arg switches the "what" field, to e.g. "news"
6
7test "${1}" = "" && echo 'Needs an argument to search for!' && exit 1
8WHAT="web"
9test "${2}" && WHAT="${2}"
10
11# convert multiple args
12PLUSARG="`echo $* | sed 's/ /+/g'`"
13
14# Plug in arg. only doing simple-q for now; pg=aq for advanced-query
15# embedded quotes define phrases; otherwise it goes wild on multi-words
16QB="GET /cgi-bin/query?pg=q&what=${WHAT}&fmt=c&q=\"${PLUSARG}\""
17
18# ping 'em once, to get the routing warm
19nc -z -w 8 www.altavista.digital.com 24015 2> /dev/null
20echo "=== Altavista ==="
21
22for xx in 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 \
23 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 ; do
24 echo "${QB}&stq=${xx}" | nc -w 15 www.altavista.digital.com 80 | \
25 egrep '^<a href="http://'
26done
27
28exit 0
29
30# old filter stuff
31 sed -e '/Documents .* matching .* query /,/query?.*stq=.* Document/p' \
32 -e d
33