Documentation
¶
Overview ¶
Package ankhang is the library behind the ankhang command line: the HTTP client, HTML scraping, and typed data models for An Khang Pharmacy (www.ankhangpharma.com), one of Vietnam's top pharmacy chains.
Product detail pages embed JSON-LD Product schema for structured data. Category listings are scraped from HTML link tags. Product URLs follow the pattern: https://www.ankhangpharma.com/{category}/{slug}.html.
Index ¶
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.
const Host = "www.ankhangpharma.com"
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 An Khang Pharmacy website over HTTP.
func NewClientWithConfig ¶
NewClientWithConfig returns a Client built from cfg.
func (*Client) Get ¶
Get fetches rawURL and returns the body bytes, pacing and retrying on transient errors.
func (*Client) GetProduct ¶
GetProduct fetches a product detail page by its slug (category/name-slug, no .html).
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 An Khang Pharmacy kit driver.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
type Product ¶
type Product struct {
Slug string `json:"slug" kit:"id" table:"slug"`
Name string `json:"name" table:"name"`
URL string `json:"url,omitempty" table:"url,url"`
Price float64 `json:"price" table:"price"`
Category string `json:"category,omitempty" table:"category"`
RegistrationNumber string `json:"registration_number,omitempty" table:"reg_no"`
Brand string `json:"brand,omitempty" table:"brand"`
Manufacturer string `json:"manufacturer,omitempty" table:"manufacturer"`
OriginCountry string `json:"origin_country,omitempty" table:"origin"`
DosageForm string `json:"dosage_form,omitempty" table:"dosage_form"`
Strength string `json:"strength,omitempty" table:"strength"`
PackSize string `json:"pack_size,omitempty" table:"pack_size"`
PrescriptionRequired bool `json:"prescription_required,omitempty" table:"rx"`
Rating float64 `json:"rating,omitempty" table:"rating"`
ReviewCount int `json:"review_count,omitempty" table:"reviews"`
FetchedAt string `json:"fetched_at,omitempty" table:"fetched_at"`
}
Product is one An Khang Pharmacy product.