commit d195ecc2648dc74c89e96ed15110ef3dffe19724 from: Oliver Lowe date: Mon Sep 16 06:48:45 2024 UTC add web search program commit - 09bfa9364cdb0ab17db10c4417bb62cd0f90a173 commit + d195ecc2648dc74c89e96ed15110ef3dffe19724 blob - 34211eeea00f075deee9f14c2afbc96406edcc84 blob + 2c9ad45edef4730dc50c7a123d491e1cbd21f0cc --- README +++ README @@ -10,4 +10,5 @@ The following commands are provided: - lemmyverse - find lemmy communities - llama - prompt a large language model - webpaste - create a web paste on webpaste.olowe.co +- ws - web search - xstream - stream X display over the network blob - /dev/null blob + 08538271b51477adbf2f3dad261caf01741d8da5 (mode 755) --- /dev/null +++ bin/ws @@ -0,0 +1,20 @@ +#!/bin/sh + +firefox="Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0" + +prog=' +/duckduckgo.com\/y.js/ { next } # skip ads +/Sponsored link/ { next } # skip ads +/result-link/ { + $1=$1 + link = substr($3, index($3, "\""), length($3)) + link = substr(link, 2, length(link)-2) + + title = substr($0, index($0, ">")+1, length) + title = substr(title, 1, index(title, "<")-1) + print link + print "\t" title +} +' + +curl -s -d "q=$@" -H "User-Agent: $firefox" https://lite.duckduckgo.com/lite/ | awk "$prog" blob - /dev/null blob + ec351ed962852490fdd5216e9e6c1cd26d7118fe (mode 644) --- /dev/null +++ man/ws.1 @@ -0,0 +1,38 @@ +.Dd +.Dt WS 1 +.Sh NAME +.Nm ws +.Nd web search +.Sh SYNOPSIS +.Nm +.Ar query ... +.Sh DESCRIPTION +.Nm +sends the query to a web search engine +.Pq default DuckDuckGo +and prints the results to the standard output. +.Sh EXAMPLE +.Pp +Find the Plan 9 Foundation home page: +.Dl ws Plan 9 foundation +.Pp +Search the web for motorcycle parts for +Yamaha's discontinued dual-sport motorcycle: +.Bd -literal -offset Ds +ws '"wr250r parts"' Australia +.Ed +.Pp +The first two keywords are quoted +to include search results containing both +.Dq wr250r +and +.Dq parts . +This is again enclosed in single quotes to ensure +.Xr sh 1 +does not interpret its own quote characters. +.Sh EXIT STATUS +.Ex +.Sh SEE ALSO +.Xr curl 1 , +.Xr awk 1 , +.Lk https://duckduckgo.com/duckduckgo-help-pages/features/non-javascript/ How To Use the Non-JavaScript Version of DuckDuckGo Search