19/09/07 14:22:20.68 .net
#!/bin/zsh
# より短く分かりやすく、無駄な事をしてる部分を削った。
UNIQ=$(basename $( factor $PPID |md5sum ))
if test "${QUERY_STRING%%=*}" != $UNIQ; then # default.
URL="URLリンク(www.google.co.jp)
else case "$QUERY_STRING" in
# formから流れてくるもの。# 次のページへ、時間指定等の対応。
${UNIQ}=form\&*|${UNIQ}=rotate\&*)
URL="URLリンク(www.google.co.jp)( cut -d '&' -f 2- <<<$QUERY_STRING )";;
${UNIQ}=decode\&*) # ここから再検索して下さいの対処。
URL="URLリンク(www.google.co.jp)
$(nkf --url-input <( sed 's/\([^&]*&\)\{2\}//; s/%25/%/g' <<<$QUERY_STRING ))";;
esac
fi
<<EOF
Content-Type: text/plain
w3m-control: GOTO $URL
w3m-control: VIEW
w3m-control: PIPE_BUF sed 's%\(<input[^>]*\)Shift_JIS%\1UTF-8%; s%\(<form \)\([^>]*>\)'\
'%\1action="file:///cgi-bin/google.zsh" \2<input name=$UNIQ type=hidden value="form">%;'\
's%\(<span[^>]*>\|</span>\)%%g; s%<div[^>]*>%%g; s%</div>%<div>&%g;'\
's,\(<a [^>]*href="\)/url?q=/search%3F\(q%3D[^"]*"\)'\
',\1file:///cgi-bin/google.zsh?${UNIQ}=decode\&\2,;'\
's%\(<a [^>]*href="\)/url?%\1URLリンク(www.google.co.jp)'\
's%\(<a [^>]*href="\)/search?\([^"]*"\)'\
'%\1file:///cgi-bin/google.zsh?${UNIQ}=rotate\&\2%g'
w3m-control: VIEW
$( printf '%s\n' 'w3m-control: DELETE_PREVBUF'{,,,} )
EOF