Documentation
¶
Overview ¶
Package sendo is the library behind the sendo command line: the HTTP client, API parsing, and typed data models for Sendo (sendo.vn), a major Vietnamese e-commerce marketplace.
Sendo exposes an internal JSON API for product details. Listing pages and search results are parsed from HTML via JSON-LD or regex extraction. Product URLs follow the pattern: https://www.sendo.vn/{slug}-{id}.html.
Index ¶
- Constants
- type Client
- func (c *Client) CategoryProducts(ctx context.Context, slug string, limit int) ([]*Product, error)
- func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)
- func (c *Client) GetProduct(ctx context.Context, id string) (*Product, error)
- func (c *Client) SearchProducts(ctx context.Context, query string, limit int) ([]*Product, error)
- type Config
- type Domain
- type Product
Constants ¶
const DefaultUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"
DefaultUserAgent mimics a real browser to avoid Cloudflare blocks.
const Host = "sendo.vn"
Host is the canonical site hostname.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the Sendo website over HTTP.
func NewClientWithConfig ¶
NewClientWithConfig returns a Client built from cfg.
func (*Client) CategoryProducts ¶
CategoryProducts fetches products from a category listing page.
func (*Client) Get ¶
Get fetches rawURL and returns the body bytes, pacing and retrying on transient errors.
func (*Client) GetProduct ¶
GetProduct fetches full details for a single product by numeric ID.
type Config ¶
type Config struct {
BaseURL string
Rate time.Duration
Retries int
Timeout time.Duration
UserAgent string
}
Config holds the tunable knobs for the HTTP client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible production defaults.
type Domain ¶
type Domain struct{}
Domain is the Sendo driver.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
type Product ¶
type Product struct {
ID string `json:"id" kit:"id" table:"id"`
Name string `json:"name" table:"name"`
URL string `json:"url,omitempty" table:"url,url"`
Price float64 `json:"price" table:"price"`
OriginalPrice float64 `json:"original_price,omitempty" table:"original_price"`
DiscountPercent int `json:"discount_percent,omitempty" table:"discount_percent"`
SellerName string `json:"seller_name,omitempty" table:"seller_name"`
SellerRating float64 `json:"seller_rating,omitempty" table:"seller_rating"`
Rating float64 `json:"rating,omitempty" table:"rating"`
ReviewCount int `json:"review_count,omitempty" table:"reviews"`
SoldCount int64 `json:"sold_count,omitempty" table:"sold"`
IsAuthentic bool `json:"is_authentic,omitempty" table:"authentic"`
IsFreeShip bool `json:"is_freeship,omitempty" table:"freeship"`
Location string `json:"location,omitempty" table:"location"`
FetchedAt string `json:"fetched_at,omitempty" table:"fetched_at"`
}
Product is one Sendo product fetched from the internal API.