v2api

package module
v0.0.0-...-619dd30 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: MIT Imports: 9 Imported by: 1

README

v2api

Documentation

Index

Constants

View Source
const (
	URL_HOME   = "https://www.v2ex.com"
	URL_NODE   = URL_HOME + "/go/"
	URL_RECENT = URL_HOME + "/recent"
	URL_PLANES = URL_HOME + "/planes"
	URL_MEMBER = URL_HOME + "/member/"
)

Variables

View Source
var (
	ErrNotLogin = errors.New("Not login")

	ErrTopicNotExist = errors.New("Topic is not exist")
	ErrNodeNotExist  = errors.New("Node is not exist")
	ErrUserNotExist  = errors.New("User is not exist")
)

Functions

This section is empty.

Types

type Balance

type Balance struct {
	Gold   int
	Silver int
	Bronze int
	Money  float32
}

Balance

type Client

type Client struct {
	// contains filtered or unexported fields
}
var DefaultClient *Client

func NewClient

func NewClient() *Client

func (*Client) Community

func (c *Client) Community() (com *Community, err error)

Community 社区数据

func (*Client) Content

func (c *Client) Content(id int64, replyPage int) (ctt *Content, err error)

Content replyPage 回复列表页数 从1开始 为0则最新页

func (*Client) HasLoggedIn

func (c *Client) HasLoggedIn() bool

func (*Client) Hots

func (c *Client) Hots() (topics []*Topic, err error)

Hots 今日热议主题

func (*Client) Latest

func (c *Client) Latest() (topics []*Topic, err error)

Latest 首页最新

func (*Client) Member

func (c *Client) Member(name string) (mem *Member, err error)

Member 会员数据

func (*Client) Node

func (c *Client) Node(node string, page int) (list *List, err error)

Node 节点主题

func (*Client) Planes

func (c *Client) Planes() (nodes []*Node, err error)

Planes 位面列表

func (*Client) Profile

func (c *Client) Profile() (pro *Profile, err error)

Profile 个人资料

func (*Client) Recent

func (c *Client) Recent(page int) (list *List, err error)

Recent 最近主题

func (*Client) SetCookie

func (c *Client) SetCookie(cookie string)

func (*Client) TopPlay

func (c *Client) TopPlay() ([]*Leaderboard, error)

TopPlay 消费排行

func (*Client) TopRich

func (c *Client) TopRich() ([]*Leaderboard, error)

TopRich 财富排行

type Community

type Community struct {
	// 首页右侧
	Members  int // 会员
	Topics   int // 主题
	Comments int // 回复

	// 首页底部
	Version   string // 版本
	Online    int    // 当前在线
	OnlineMax int    // 最高在线
}

Community 社区数据

type Content

type Content struct {
	Topic        *Topic
	Body         string
	Clicks       int
	Favorites    int
	Thanks       int
	Postscripts  []*Postscript
	Replies      []*Reply
	ReplyTotal   int
	ReplyTime    time.Time
	ReplyPage    int
	ReplyPageMax int
}

Content 主题内容

type Leaderboard

type Leaderboard struct {
	Index    int
	UserName string
	Balance  *Balance
}

Leaderboard 排行榜 财富排行榜 https://www.v2ex.com/top/rich 消费排行榜 https://www.v2ex.com/top/player

type List

type List struct {
	Topics  []*Topic
	Total   int
	Page    int
	PageMax int
	NodeBio string
	NodeImg string
}

List 主题列表

type Member

type Member struct {
	Name     string
	Bio      string
	Avatar   string
	Number   int
	Join     string
	JoinTime time.Time
	Rank     int
	Online   bool
}

Member 会员数据 https://www.v2ex.com/member/livid

type Node

type Node struct {
	Name   string
	URL    string
	Type   string
	TypeCN string
}

Node 节点 https://www.v2ex.com/planes

type Postscript

type Postscript struct {
	Content     string
	Publish     string
	PublishTime time.Time
}

Postscript 主题附言

type Profile

type Profile struct {
	UserName      string
	UserUrl       string
	Avatar        string
	FavNodes      int
	FavTopics     int
	Following     int
	Notifications int
	Balance       *Balance
}

Profile 个人资料

type Reply

type Reply struct {
	Author      string
	AuthorUrl   string
	Avatar      string
	Number      int
	Content     string
	Publish     string
	PublishTime time.Time
}

Reply 主题回复

type Topic

type Topic struct {
	Title       string
	Link        string
	Author      string
	AuthorUrl   string
	Avatar      string
	Votes       int
	Comments    int
	Reply       string
	Node        string
	NodeUrl     string
	Publish     string
	PublishTime time.Time
}

Topic 主题

Jump to

Keyboard shortcuts

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