laodong

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package laodong is the library behind the laodong command line: the HTTP client, RSS feed parsing, and typed data models for Lao Động (laodong.vn), Vietnam's labor-union-affiliated general news daily.

Lao Động publishes per-category RSS 2.0 feeds. Article URLs embed a numeric ID: /{category}/{slug}-{id}.html.

Index

Constants

View Source
const DefaultUserAgent = "laodong-cli/0.1.0 (+https://github.com/tamnd/laodong-cli)"

DefaultUserAgent identifies this client to Lao Động.

View Source
const Host = "laodong.vn"

Host is the canonical site hostname.

Variables

View Source
var Categories = []string{
	"home",
	"thoi-su",
	"lao-dong-viec-lam",
	"cong-doan",
	"xa-hoi",
	"kinh-te",
	"the-gioi",
	"phap-dinh",
	"giao-duc",
	"suc-khoe",
	"van-hoa",
	"the-thao",
	"cong-nghe",
}

Categories lists Lao Động's RSS feed category slugs.

Functions

This section is empty.

Types

type Article

type Article struct {
	ID          string `json:"id"                   kit:"id" table:"id"`
	Title       string `json:"title"                          table:"title"`
	URL         string `json:"url,omitempty"                  table:"url,url"`
	Category    string `json:"category,omitempty"             table:"category"`
	Description string `json:"description,omitempty"          table:"-"`
	Author      string `json:"author,omitempty"               table:"author"`
	Thumbnail   string `json:"thumbnail,omitempty"            table:"-"`
	PublishedAt string `json:"published_at,omitempty"         table:"published_at"`
}

Article is one Lao Động article extracted from an RSS feed.

type Category

type Category struct {
	Slug string `json:"slug" kit:"id" table:"slug"`
	Name string `json:"name"          table:"name"`
	URL  string `json:"url"           table:"url,url"`
	RSS  string `json:"rss"           table:"-"`
}

Category represents one Lao Động RSS feed category.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to Lao Động RSS feeds over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client from DefaultConfig.

func NewClientWithConfig

func NewClientWithConfig(cfg Config) *Client

NewClientWithConfig returns a Client built from cfg.

func (*Client) CategoryArticles

func (c *Client) CategoryArticles(ctx context.Context, slug string, limit int) ([]*Article, error)

CategoryArticles fetches articles for the given category slug from its RSS feed.

func (*Client) Get

func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)

Get fetches rawURL and returns the body bytes, pacing and retrying on transient errors.

func (*Client) LatestArticles

func (c *Client) LatestArticles(ctx context.Context, limit int) ([]*Article, error)

LatestArticles fetches the most recent articles from the home RSS feed.

func (*Client) ListCategories

func (c *Client) ListCategories() []*Category

ListCategories returns all known Lao Động RSS feed categories.

func (*Client) SearchArticles

func (c *Client) SearchArticles(ctx context.Context, query string, limit int) ([]*Article, error)

SearchArticles keyword-searches across several category feeds.

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 Lao Động driver.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns a Lao Động URL or numeric ID into (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Jump to

Keyboard shortcuts

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