Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit

Permalink
add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
songjiaxin committed Aug 11, 2020
1 parent 2d64465 commit e4d4d89
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
)

// 获取置顶文章pid以及作者信息
func GetPinnedArticlePidAndAuthor(columnName string) (*PinnedArticleAndAuthor, error) {
if columnName == "" {
return nil, ColumnNameCanNotBeEmpty
Expand All @@ -23,6 +24,7 @@ func GetPinnedArticlePidAndAuthor(columnName string) (*PinnedArticleAndAuthor, e
return &pinnedArticleAndAuthor, nil
}

// 获取单个文章
func GetSingleArticle(pid int) (*Article, error) {
if pid == 0 {
return nil, PidCanNotBeEmpty
Expand All @@ -42,6 +44,7 @@ func GetSingleArticle(pid int) (*Article, error) {
return &article, nil
}

// 获取文章pid列表
func GetArticlesListPids(columnName string) ([]int, error) {
if columnName == "" {
return nil, ColumnNameCanNotBeEmpty
Expand Down
6 changes: 6 additions & 0 deletions model.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package ZhihuZhuanlanCrawler

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

// 作者
type Author struct {
ID string `json:"id"`
Name string `json:"name"`
Expand All @@ -19,6 +21,7 @@ type Author struct {
UserType string `json:"user_type"`
}

// 置顶文章及作者信息
type PinnedArticleAndAuthor struct {
Type string `json:"type"`
ID int `json:"id"`
Expand All @@ -31,13 +34,15 @@ type PinnedArticleAndAuthor struct {
Author Author
}

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

// 文章
type Article struct {
ID int `json:"id"`
Type string `json:"type"`
Expand All @@ -51,6 +56,7 @@ type Article struct {
Topics []Topic `json:"topics"`
}

// 文章列表
type ArticleList struct {
Paging struct {
IsEnd bool `json:"is_end"`
Expand Down
5 changes: 0 additions & 5 deletions renovate.json

This file was deleted.

0 comments on commit e4d4d89

Please sign in to comment.