ZhihuZhuanlanCrawler

package module
v0.0.0-...-37a0b56 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2021 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

ZhihuZhuanlanCrawler

知乎专栏爬虫

screenshot1.png

测试爬虫功能

go test -run TestCrawl -v

具体用法可以参考 crawler_test.go。

go doc https://godoc.org/github.com/solarhell/ZhihuZhuanlanCrawler

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ColumnNameCanNotBeEmpty = errors.New("专栏名不能为空")
	PidCanNotBeEmpty        = errors.New("pid 不能为空")
)

Functions

func GetArticlesListPids

func GetArticlesListPids(columnName string) ([]int, error)

获取文章pid列表

Types

type Article

type Article struct {
	ID       int     `json:"id"`
	Type     string  `json:"type"`
	Title    string  `json:"title"`
	URL      string  `json:"url"`
	Updated  int64   `json:"updated"`
	Created  int64   `json:"created"`
	Excerpt  string  `json:"excerpt"`
	Content  string  `json:"content"`
	ImageURL string  `json:"image_url"`
	Topics   []Topic `json:"topics"`
}

文章

func GetSingleArticle

func GetSingleArticle(pid int) (*Article, error)

获取单个文章

type ArticleList

type ArticleList struct {
	Paging struct {
		IsEnd   bool `json:"is_end"`
		Totals  int  `json:"totals"`
		IsStart bool `json:"is_start"`
	} `json:"paging"`
	Data []struct {
		ID int `json:"id"`
	} `json:"data"`
}

文章列表

type Author

type Author struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Gender      int    `json:"gender"`
	Headline    string `json:"headline"`
	Description string `json:"description"`
	AvatarUrl   string `json:"avatar_url"`
	Type        string `json:"type"`
	UID         string `json:"uid"`
	URL         string `json:"url"`
	URLToken    string `json:"url_token"`
	UserType    string `json:"user_type"`
}

作者

type PinnedArticleAndAuthor

type PinnedArticleAndAuthor struct {
	Type     string `json:"type"`
	ID       int    `json:"id"`
	Updated  int64  `json:"updated"`
	Created  int64  `json:"created"`
	Title    string `json:"title"`
	ImageURL string `json:"image_url"`
	URL      string `json:"url"`
	Excerpt  string `json:"excerpt"`
	Author   Author
}

置顶文章及作者信息

func GetPinnedArticlePidAndAuthor

func GetPinnedArticlePidAndAuthor(columnName string) (*PinnedArticleAndAuthor, error)

获取置顶文章pid以及作者信息

type Topic

type Topic struct {
	Url  string `json:"url"`
	Type string `json:"type"`
	Id   string `json:"id"`
	Name string `json:"name"`
}

主题

type Zhuanlan

type Zhuanlan struct {
	Slug string `json:"slug"`
	Name string `json:"name"`
}

专栏

Jump to

Keyboard shortcuts

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