Documentation
¶
Overview ¶
Package olxvn is the library behind the olxvn command line: the HTTP client, HTML scraping, and typed data models for OLX Vietnam (olx.vn), a top-10 classifieds platform in Vietnam.
Listing detail pages embed JSON-LD Product/Offer schema for core fields. Category listing pages use ?page=N pagination. Listing URLs follow the pattern: https://www.olx.vn/item/{slug}/.
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.olx.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 OLX Vietnam 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) GetListing ¶
GetListing fetches a listing detail page by its slug.
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 OLX Vietnam kit driver.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
type Listing ¶
type Listing struct {
// Slug is the item slug from the URL: the canonical ID.
Slug string `json:"slug" kit:"id" table:"slug"`
Title string `json:"title" table:"title"`
URL string `json:"url,omitempty" table:"url,url"`
Price float64 `json:"price,omitempty" table:"price"`
PriceNegotiable bool `json:"price_negotiable,omitempty" table:"negotiable"`
Description string `json:"description,omitempty" table:"-"`
Category string `json:"category,omitempty" table:"category"`
City string `json:"city,omitempty" table:"city"`
Condition string `json:"condition,omitempty" table:"condition"`
SellerName string `json:"seller_name,omitempty" table:"seller"`
PostedAt string `json:"posted_at,omitempty" table:"posted_at"`
FetchedAt string `json:"fetched_at,omitempty" table:"fetched_at"`
}
Listing is one OLX Vietnam classified ad.