Documentation ¶
Overview ¶
Package cexfind searches for devices for sale at Cex/Webuy via the unofficial "webuy.io" query endpoint which responds in a json format.
Queries are required to be made in the UK as the endpoint is protected by region-sensitive CDN.
Multiple concurrent queries are supported, with an optional "strict" flag to constrain results to the query terms. The results are a union of the results of each query, ordered by model name and then the price of each item.
Example usage:
results, err := cex.Search(queries, strict) if err != nil { log.Fatal(err) } latestModel := "" for _, box := range results { if box.Model != latestModel { fmt.Printf("\n%s\n", box.Model) latestModel = box.Model } fmt.Printf( " £%3d %s\n %s\n", box.Price, box.Name, box.IDUrl(), ) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
// URL is the Cex/Webuy search endpoint
URL = "https://search.webuy.io/1/indexes/*/queries"
)
Functions ¶
This section is empty.
Types ¶
type Box ¶
Box is a very simplified representation of a Cex/Webuy json entry, where each entry represents a "Box" or computer or other item for sale.
func Search ¶
Search searches the Cex json endpoint at URL for the provided queries, returning a slice of Box or error.
The strict flag ensures that the results contain terms from the search queries as the non-strict results include additional suggestions from the Cex/Webuy system.
Multiple queries are run concurrently and their results sorted by model, then by price ascending. Duplicate results are removed at aggregation.