google-search: github.com/rocketlaunchr/google-search Index | Files

package googlesearch

import "github.com/rocketlaunchr/google-search"

Index

Package Files

search.go

Variables

var GoogleDomains = map[string]string{
    "us": "https://www.google.com/search?q=",
    "gb": "https://www.google.co.uk/search?q=",
    "ru": "https://www.google.ru/search?q=",
    "fr": "https://www.google.fr/search?q=",
    "au": "https://www.google.com.au/search?q=",
    "nz": "https://www.google.co.nz/search?q=",
}

GoogleDomains represents localized Google homepages. The 2 letter country code is based on ISO 3166-1 alpha-2.

PR's are welcome.

See: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

type Result Uses

type Result struct {

    // Rank is the order number of the search result.
    Rank int `json:"rank"`

    // URL of result.
    URL string `json:"url"`

    // Title of result.
    Title string `json:"title"`

    // Description of the result.
    Description string `json:"description"`
}

Result represents a single result from Google Search.

func Search(ctx context.Context, searchTerm string, opts ...SearchOptions) ([]Result, error)

Search returns a list of search results from Google.

type SearchOptions Uses

type SearchOptions struct {

    // CountryCode sets the ISO 3166-1 alpha-2 code of the localized Google Search homepage to use.
    // The default is "us", which will return results from https://www.google.com.
    CountryCode string

    // LanguageCode sets the language code.
    // Default: en
    LanguageCode string

    // Limit sets how many results to fetch (at maximum).
    Limit int

    // Start sets from what rank the new result set should return.
    Start int

    // UserAgent sets the UserAgent of the http request.
    // Default: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"
    UserAgent string
}

SearchOptions modifies how the Search function behaves.

Package googlesearch imports 4 packages (graph). Updated 2020-03-12. Refresh now. Tools for package owners.