Documentation ¶
Index ¶
- func ConvertListURL(URL string) string
- func ExtractPartListURLs(text string) []string
- func ExtractVendorName(URL string) string
- func MatchPCPPURL(URL string) bool
- func MatchPartListURL(URL string) bool
- func MatchProductURL(URL string) bool
- func StringPriceToFloat(price string) (float64, string, error)
- type CompNote
- type Part
- type PartList
- type PartListPart
- type Price
- type Rating
- type RedirectError
- type Scraper
- type SearchPart
- type Spec
- type Vendor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertListURL ¶
Converts certain PCPartPicker list URLs to a specific format in order to prevent client side JS loading.
func ExtractPartListURLs ¶
Returns a list of all valid PCPartPicker part list URLs in the provided text.
func ExtractVendorName ¶
Extracts the name of a vendor from a PCPartPicker affiliate link.
func MatchPCPPURL ¶
Checks if a URL is a PCPartPicker URL, making sure to check all regional subdomains.
func MatchPartListURL ¶
Check if a URL is a PCPartPicker part list URL.
func MatchProductURL ¶
Checks if a URL is PCPartPicker product URL.
Types ¶
type CompNote ¶
type CompNote struct { // The compatibility note's message. Message string // The level or severity of the note, e.g. Warning, Note. Level string }
A compatibility note for a part list.
type Part ¶
type Part struct { // The part's type, e.g. CPU, Motherboard. Type string // The part's name. Name string // A slice of full image URLs. Images []string // The full URL for the part's PCPartPicker page. URL string // A slice of vendors supplying the part. Vendors []Vendor // The specifications of the part. Specs []Spec // The part's rating. Rating Rating }
A full part object with multiple vendors and reviews.
type PartList ¶
type PartList struct { // The full URL for the part list. URL string // The parts in the part list. Parts []PartListPart // The price of all the part list's parts combined. Price Price // The total estimated wattage for the part list. Wattage string // Compatibility notes for the part list. Compatibility []CompNote }
Represents a PCPartPicker part list.
type PartListPart ¶
type PartListPart struct { // The part's type, e.g. CPU, Motherboard. Type string // The part's name. Name string // The full URL for the part's image. Image string // The full URL for the part's PCPartPicker page. URL string // The vendor for the part that is offering it for the lowest price. Vendor Vendor }
A part from a part list. It has some data missing, such as all available vendors and specs.
type Price ¶
type Price struct { // The base price of the item, without shipping, discounts or tax. Base float64 // The price of shipping for the item. Shipping float64 // The price of tax for the item. Tax float64 // The price of discounts for the item. Discounts float64 // The total price of the item. Total float64 // The currency of the price of the item, e.g. £, $. Currency string // A string representing the item's total price, e.g. $1000 or 5500 RON. TotalString string }
Represents the total price of an item as well as additional fees.
type RedirectError ¶
type RedirectError struct {
URL string
}
func (RedirectError) Error ¶
func (r RedirectError) Error() string
type Scraper ¶
type Scraper struct { // The Colly collector used for scraping. Collector *colly.Collector Headers map[string]map[string]string }
func (Scraper) GetPartList ¶
Fetches data on a part list via URL.
func (Scraper) SearchParts ¶
func (s Scraper) SearchParts(searchTerm string, region string) ([]SearchPart, error)
Searches for parts using PCPartPicker's search function.
type SearchPart ¶
type SearchPart struct { // The part's name. Name string // The full URL for the part's image. Image string // The full URL for the part's PCPartPicker page. URL string // The vendor for the part that is offering it for the lowest price. Vendor Vendor }
A part from PCPartPicker search results. It has a lot of data missing, such as full pricing information.
type Vendor ¶
type Vendor struct { // The name of the vendor. Name string // The full URL for the vendor's image. Image string // Whether the vendor has the part in stock or not. InStock bool // The vendor's price for the part. Price Price // The full, affiliate URL to buy the part from. URL string }
The seller of a part.