search

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2023 License: MIT Imports: 15 Imported by: 0

README

Use privacy mode (on by default) to search brave, duck duck go, mojeek, and qwant and non-privacy mode to search bing, brave, duck duck go, and yahoo. Prints search result URLs and blurbs to stdout.

installation

go install github.com/davemolk/search@latest or run one of the binaries included in the repo

examples

combine additional search terms with your base query (terms are added one at a time) search -s golang cloud cli gophers

https://search.brave.com/search?q=golang+cloud
https://html.duckduckgo.com/html?q=golang+cloud
https://www.mojeek.com/search?q=golang+cloud
https://lite.qwant.com/?q=golang+cloud
https://search.brave.com/search?q=golang+cli
https://html.duckduckgo.com/html?q=golang+cli
https://www.mojeek.com/search?q=golang+cli
https://lite.qwant.com/?q=golang+cli
https://search.brave.com/search?q=golang+gophers
https://html.duckduckgo.com/html?q=golang+gophers
https://www.mojeek.com/search?q=golang+gophers
https://lite.qwant.com/?q=golang+gophers

combine additional search terms with your base query (use -m to handle multiple terms) search -s golang -m cloud cli gophers

https://search.brave.com/search?q=golang+cloud+cli+gophers
https://html.duckduckgo.com/html?q=golang+cloud+cli+gophers
https://www.mojeek.com/search?q=golang+cloud+cli+gophers
https://lite.qwant.com/?q=golang+cloud+cli+gophers

combine a mix of single and multiple additional search terms with your base query (use -m and cat in your list of terms)

$ cat terms.txt
microservices
cloud technology
machine learning
cli

cat terms.txt | search -s golang -m

https://search.brave.com/search?q=golang+microservices
https://html.duckduckgo.com/html?q=golang+microservices
https://www.mojeek.com/search?q=golang+microservices
https://lite.qwant.com/?q=golang+microservices
https://search.brave.com/search?q=golang+cloud+technology
https://html.duckduckgo.com/html?q=golang+cloud+technology
https://www.mojeek.com/search?q=golang+cloud+technology
https://lite.qwant.com/?q=golang+cloud+technology
https://search.brave.com/search?q=golang+machine+learning
https://html.duckduckgo.com/html?q=golang+machine+learning
https://www.mojeek.com/search?q=golang+machine+learning
https://lite.qwant.com/?q=golang+machine+learning
https://search.brave.com/search?q=golang+cli
https://html.duckduckgo.com/html?q=golang+cli
https://www.mojeek.com/search?q=golang+cli
https://lite.qwant.com/?q=golang+cli

flags

[customize basic query info]
-m  include multiple terms within a single query
	search -s foo -m bar baz => https://search.brave.com/search?q=foo+bar+baz, etc.
	default: false

-n  no additional search terms
	search -s foo => https://search.brave.com/search?q=foo, etc.
	default: false
	
-p  privacy mode (when true, searches brave, duck duck go, mojeek, and qwant,
	otherwise, searches bing, duck duck go, brave, and yahoo)
	default: true

-s  base search term(s)
    search -s "foo bar" baz => https://seach.brave.com/search?q=foo+bar+baz


[customize exact searching]
-e  exact searching for entire query
	search -s foo bar -e => https://search.brave.com/search?q="foo+bar", etc.
	default: false

-me exact matching for additional terms
	search -s foo -me bar baz => https://search.brave.com/search?q=foo+"bar+baz", etc.
    default: false

-se exact matching for search term(s)
	search -s "foo bar" -se baz => https://search.brave.com/search?q="foo+bar"+baz, etc.
	default: false


[customize requests]
-c  max number of concurrent requests
	default: 10

-os operating system (used for creating browser headers)
	arguments: any, l, m, or w
	default: w

-t  request timeout, in ms
	default: 5000


[customize output]
-l  length of result summary
	default: 500

-u  include result urls in output
	default: true


help
-d  print the search url to help debug queries
	default: false
-h  help`)

Note

Each request gets a randomly assigned user agent corresponding to your os as well as appropriate headers (50/50 chance of chrome or firefox, thanks fuzzyHelpers). Go unfortunately doesn't preserve header order, so if that's important to you and what you're up to, you'll have to look elsewhere.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSearchTerm = errors.New("must provide search term(s)")
	ErrInvalidOS    = errors.New("os must be l, m, or w")
)

Functions

func FromArgs

func FromArgs(args []string) option

func NewSearcher

func NewSearcher(opts ...option) (*searcher, error)

func RunCLI

func RunCLI()

func WithInput

func WithInput(input io.Reader) option

func WithOutput

func WithOutput(output io.Writer) option

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL