search

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

search for devices for sale at Cex

Index

Constants

This section is empty.

Variables

View Source
var (
	//URL search url
	URL = "https://search.webuy.io/1/indexes/*/queries"
	// MODEL placeholder
	MODEL = "MODEL"
	// json body with placeholder; note that the availability online filter ensures only available kit is returned
	BODY = `` /* 402-byte string literal not displayed */
	// detail url placeholder
	URLDETAIL = "https://uk.webuy.com/product-detail?id="
	// save web output to temp file if DEBUG true
	DEBUG = false
)

Functions

This section is empty.

Types

type Box

type Box struct {
	Model string
	Name  string
	ID    string
	Price int
}

Box is a rationalised JsonResults.Results.Hits entry, notionally representing a "Box" or computer or other item for sale

type BoxMap

type BoxMap map[string]boxes

BoxMap is a map of boxes by model name

func Search(queries []string, strict bool) (BoxMap, error)

Search searches the Cex json endpoint at URL for the provided queries, returning a BoxMap or error. The strict flag ensures that the results contain terms from the search queries

func (BoxMap) Iter

func (b BoxMap) Iter() <-chan boxMapIter

Iter iterates over a BoxMap returning a key, Box pair over the whole BoxMap collection

type JsonResults

type JsonResults struct {
	Results []struct {
		Hits []struct {
			BoxName string `json:"boxName"`
			BoxID   string `json:"boxId"`
			// Available int `json:"collectionQuantity"` // returns 0 or greater
			Price int `json:"sellPrice"`
		} `json:"hits"`
		NbHits      int `json:"nbHits"`
		HitsPerPage int `json:"hitsPerPage"`
	} `json:"results"`
}

JsonResults encompasses the interesting fields in a Cex web search result

Jump to

Keyboard shortcuts

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