api

package
v0.0.0-...-0eb5215 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseURL   = "https://www.v2ex.com"
	UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client V2EX HTTP 客户端

func NewClient

func NewClient() *Client

NewClient 创建新的 HTTP 客户端

func (*Client) BuildURL

func (c *Client) BuildURL(path string) string

BuildURL 构建完整 URL

func (*Client) Get

func (c *Client) Get(path string) (*goquery.Document, error)

Get 发送 GET 请求并返回解析后的 HTML 文档

func (*Client) GetCurrentUser

func (c *Client) GetCurrentUser() (*model.User, error)

GetCurrentUser 获取当前登录用户信息

func (*Client) GetRaw

func (c *Client) GetRaw(path string) (*resty.Response, error)

GetRaw 发送 GET 请求并返回原始响应

func (*Client) GetTopicDetail

func (c *Client) GetTopicDetail(topicURL string) (*model.Topic, []model.Reply, error)

GetTopicDetail 获取帖子详情和回复

func (*Client) GetTopicDetailPage

func (c *Client) GetTopicDetailPage(topicURL string, page int) (*model.Topic, []model.Reply, error)

GetTopicDetailPage 获取帖子详情和指定页码的回复

func (*Client) GetTopicsByNode

func (c *Client) GetTopicsByNode(nodeCode string, page int) (*NodeTopicsResult, error)

GetTopicsByNode 按节点获取主题列表

func (*Client) GetTopicsByTab

func (c *Client) GetTopicsByTab(tab string) ([]model.Topic, []model.Node, *model.User, error)

GetTopicsByTab 按 Tab 获取主题列表,同时返回二级节点列表和用户信息

func (*Client) Login

func (c *Client) Login(username, password string) (*model.User, error)

Login 用户登录 (暂时简化实现,后续需要处理验证码等)

func (*Client) Logout

func (c *Client) Logout() error

Logout 退出登录

func (*Client) Post

func (c *Client) Post(path string, data map[string]string) (*goquery.Document, error)

Post 发送 POST 请求并返回解析后的 HTML 文档

func (*Client) SetCookies

func (c *Client) SetCookies(cookies []*http.Cookie)

SetCookies 设置登录 Cookie

type NodeTopicsResult

type NodeTopicsResult struct {
	Topics     []model.Topic
	TotalPages int
}

NodeTopicsResult 节点主题列表结果

Jump to

Keyboard shortcuts

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