Documentation
¶
Index ¶
Constants ¶
const ( // HTTPTimeout is the time limit for requests made by this // Client. HTTPTimeout = time.Minute * 5 // IdleConnections controls the maximum number of idle (keep-alive) // connections across all hosts. Zero means no limit. IdleConnections = 50 // DefaultCountry is the country used to obtain serps when // no country is passed via the Options. DefaultCountry = "uk" // DefaultCacheExpiry is the amount of time the response data // will live in the cache. DefaultCacheExpiry = 8 * time.Hour // PrefixCacheKey is the string prepended before the cache key. PrefixCacheKey = "luminati-client" )
Variables ¶
var ( // ErrClientTimeout is returned the by the client when the // context deadline has exceeded. ErrClientTimeout = errors.New(context.DeadlineExceeded.Error() + " (Luminati.Client.Timeout exceeded while awaiting headers)") )
var ( // ErrNoKeywordProvided is returned by validate when no keyword // was provided to the Options struct. ErrNoKeywordProvided = errors.New("error: no keyword provided to options") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
BaseURL string
CacheExpiry time.Duration
HasCache bool
// contains filtered or unexported fields
}
Client is an HTTP Client for returning and obtaining data from the Luminati API.
func New ¶
New creates a new Luminati client, an error will be returned if there was an issue parsing the proxy URL.
func NewWithCache ¶
NewWithCache creates a new Luminati client, with a cache store and default CacheExpiry, If the redigo.Store (Cache) interface passed is nil and error will be returned.
type KeywordFinder ¶
type KeywordFinder interface {
// JSON Retrieves json from the search and returns a return struct
// after processing.
//
// Returns an if the options failed validation, the request failed
// or if there was a problem unmarshalling the response.
JSON(ctx context.Context, o Options) (Serps, Meta, error)
// HTML Retrieves raw HTML from the search and returns a string
// of the result.
//
// Returns an if the options failed validation or the request
// failed.
HTML(ctx context.Context, o Options) (string, Meta, error)
}
KeywordFinder defines the methods used for finding Serp data through the Luminati API.
type Meta ¶
type Meta struct {
// CacheKey defines the cache key that was created
// when requesting. It's empty if no cache was used.
CacheKey string
// RequestURL is request URI that was sent to Luminati.
RequestURL string
// RequestTime is the time in which the request was
// started.
RequestTime time.Time
// ResponseTime is the time in which all processing
// was finished.
ResponseTime time.Time
// LatencyTime is the duration in which the client took
// to perform the request.
LatencyTime time.Duration
// WasCached determines if the request was cached.
WasCached bool
// Body is the request body sent back from Luminati.
Body string
}
Meta defines the information sent back from the client. It contains a cache key (if the client is using the cache). The request URL used to perform the request and response, request and latency times.
type Options ¶
type Options struct {
// Keyword is the search term used for lookup.
// NOTE: This is a required field.
Keyword string
// Country is the country to obtain data from for SERP's.
// If nothing is passed, DefaultCountry will be used.
Country string
// Params is the url.Values to be sent to google. Default
// parameters will be added if none are set such as
// lum_mobile.
Params url.Values
// Desktop is the bool defining if desktop results should
// be obtained as opposed to mobile.
Desktop bool
}
Options contains the data used for obtaining serp results from the Luminati API.
type Organic ¶
type Organic struct {
Rank int `json:"position"`
Description string `json:"text"`
Link string `json:"url"`
}
Organic represents a singular organic SERP as defined in Serps.
type Query ¶
type Query struct {
Rank int `json:"position"`
Link string `json:"url"`
Description string `json:"text"`
Features string `json:"features"`
}
Query defines the first top level