reuters

package
v0.1.1 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: 12 Imported by: 0

Documentation

Overview

Package reuters is the library behind the reuters command: the HTTP client, feed URL resolution, and RSS parsing for Reuters news.

The client fetches RSS feeds from the public Reuters agency endpoint at https://www.reutersagency.com. No authentication is required. It sets a real User-Agent, paces requests, and retries transient 429/5xx errors with exponential backoff.

Index

Constants

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

DefaultUserAgent identifies the client to Reuters.

View Source
const Host = "www.reuters.com"

Host is the Reuters site this client represents.

Variables

View Source
var ErrUnknownSection = errors.New("unknown section")

ErrUnknownSection is returned when an unknown section name is requested.

Functions

func StripHTML

func StripHTML(s string) string

StripHTML removes HTML tags and decodes common entities.

Types

type Client

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

Client fetches Reuters RSS feeds.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client with the given config.

func (*Client) Feeds

func (c *Client) Feeds() map[string]string

Feeds returns a map of section name to fully resolved feed URL.

func (*Client) FetchFeed

func (c *Client) FetchFeed(ctx context.Context, section string) ([]Item, error)

FetchFeed returns articles from the named section. section must be one of: world, business, tech, sports, lifestyle, all.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Retries   int
	Timeout   time.Duration
}

Config holds constructor parameters.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults.

type Domain added in v0.1.1

type Domain struct{}

Domain is the reuters kit driver. It carries no state; the per-run Client is built by the factory Register hands kit.

func (Domain) Info added in v0.1.1

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Register added in v0.1.1

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

Register installs the client factory and every operation onto app.

type FeedItem

type FeedItem struct {
	Name string `json:"name" kit:"id" table:"name"`
	URL  string `json:"url"           table:"url,url"`
}

FeedItem is the rendered record for the feeds command.

type Item

type Item struct {
	Title       string `json:"title"`
	Link        string `json:"link"`
	Description string `json:"description"`
	PubDate     string `json:"pub_date"`
}

Item is the public record emitted for each news article.

type NewsItem

type NewsItem struct {
	Rank    int    `json:"rank"             table:"rank"`
	Title   string `json:"title"   kit:"id" table:"title"`
	Summary string `json:"summary"          table:"summary"`
	Date    string `json:"date"             table:"date"`
	URL     string `json:"url"              table:"url,url"`
	Section string `json:"section"          table:"section"`
}

NewsItem is the rendered record for the news command.

Jump to

Keyboard shortcuts

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