On 08.12.2021 07:02,
vjp...@at.BioStrategist.dot.dot.com wrote:
> Thanks, I got it, worked on first try!! :
>
> wearch () {
> SRCH=`echo $* | sed -e 's/ /+/g'`;
> lynx -accept_all_cookies -useragent 'Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0' '
https://search.brave.com/search?q='$SRCH ;
> echo "return if enough else qwant";
> read nuff;
> if [[ -n "$nuff" ]]
> then exit
> else lynx -accept_all_cookies -useragent 'Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0' '
https://www.qwant.com/?q='$SRCH ;
> fi;
> echo "return if enough else dogpile";
> read nuff;
> if [[ -n "$nuff" ]]
> then exit
> else lynx -accept_all_cookies -useragent 'Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0' '
http://www.dogpile.com/search/web?q='$SRCH ;
> fi;
> }
Based on the code above and some comments dispersed in the thread
you may want to have a look at the subsequent code with changes
* substitution is done by shell (without sed)
* browser ID is extracted in one place
* a loop is used (simply extensible for more search engines)
* exit is replaced by return
* search will only be continued with next engine if 'y' is typed
* if no search reult are not accepted by user then status 1 is returned
* otherwise status 0
* the # commented line needs to be uncommented to operate
* the code requires a modern shell to run like ksh, bash, zsh
Hope that helps.
Janis
wearch()
{
ARGS=$*
SRCH=${ARGS// /+}
id='Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0'
for search_engine in \
'
https://search.brave.com/search' \
'
https://www.qwant.com/' \
'
http://www.dogpile.com/search/web'
do
echo "do search with $search_engine"
# lynx -accept_all_cookies -useragent "$id" "$search_engine?q=$SRCH"
echo "continue? (y/n)" ; read yn
[[ "$yn" != "y" ]] && return 0
done
echo "nothing appropriate found"
return 1
}
wearch Janis Joplin
echo search returned state $?