searchwrapper

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: MIT Imports: 6 Imported by: 0

README

go-search-google

About

go-search-google is an open-source repository for performing multiple Google searches programmatically. This library includes wait times between pagination/searches and checks to ensure that Google is not blocking the search. If Google does block the communication, an increasingly-long timeout period is utilized to prevent further blocks. This means this search method can take a long time. For quicker and more reliable searching, use Google's search API.

Use library at your own risk. Using this library inappropriately could cause unexpected blocks from Google

Usage

This repository is to be used as a package, not as a standalone program.

Example Usage

package main

import (
	"fmt"

	searchwrapper "github.com/403syph3r/go-search-google"
)

func main() {
	queries := []string{"Query 1", "Query 2"}
	options := searchwrapper.SearchParameters{}
	rec, err := searchwrapper.SearchMultiple(nil, queries, options)
	if err != nil {
		fmt.Printf("Error Encountered: %v\n", err)
	} else {
		searchwrapper.PrintResultSetPreview(rec)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRandomizedOption

func GetRandomizedOption(excludeFromList string) googlesearch.SearchOptions

func GetResultSetCounts

func GetResultSetCounts(results []ResultSet) []int

func PrintResultSetPreview

func PrintResultSetPreview(results []ResultSet)

Types

type ResultSet

type ResultSet struct {
	//Query:
	//   - The querystring utilized
	Query string `json:"query"`

	//Results:
	//   - A slice of "Result" type from google-search package
	Results []googlesearch.Result `json:"results"`
}

func SearchMultiple

func SearchMultiple(ctx context.Context, queries []string, searchOptions SearchParameters) ([]ResultSet, error)

type SearchParameters

type SearchParameters struct {
	//Aggression:
	//   - How quickly/aggressive the search wrapper should function.
	//   - Options are "H","M","L", but can be left blank. See randomization.go for more info
	Aggression string `json:"aggression"`

	//MaxResults:
	//   - How many search results should be returned per query
	//   - Passed through to google-search option
	//   - Default is 30
	MaxResults int `json:"max_results"`

	//CountryCode:
	//   - Passed through to google-search
	//   - Helps identify which Google domain to utilize
	//   - google-search sets "us" as default
	CountryCode string `json:"country_code"`

	//MaxRetries:
	//   - If blocked by Google, how many times tp keep trying before giving up
	//   - Default is 10 retries
	MaxRetries int `json:"max_retries"`

	//BlkStartWait:
	//   - When blocked by Google, the base number of seconds to wait before trying again
	//   - Default is 60 seconds
	BlkStartWait int `json:"block_start_wait_seconds"`

	//BlkInc:
	//   - When blocked by Google, the number of seconds added to the wait time
	//   - Default is 30 seconds
	BlkInc int `json:"block_increment_seconds"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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