weibo

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package weibo is the library behind the weibo command: the HTTP client, request shaping, and the typed data models for Weibo hot search.

The client fetches the public hot-search JSON endpoint at https://weibo.com/ajax/side/hotSearch. No authentication or cookies are required. It sets a real User-Agent and Referer, paces requests, and retries transient 429/5xx errors with exponential backoff.

Index

Constants

View Source
const DefaultUserAgent = "" /* 169-byte string literal not displayed */

DefaultUserAgent identifies the client to Weibo.

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 Weibo public API.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client with the given config.

func (*Client) HotSearch

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

HotSearch fetches the current Weibo hot search list. If limit > 0, only the first limit items are returned.

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 HotItem

type HotItem struct {
	Rank     int    `json:"rank"`
	Word     string `json:"word"`
	Note     string `json:"note"`
	Heat     int    `json:"heat"`
	Category string `json:"category"`
	Label    string `json:"label"`
	URL      string `json:"url"`
}

HotItem is a single entry from the Weibo hot search list.

Jump to

Keyboard shortcuts

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