bs

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseRule

func ParseRule(rule string) (string, int, int)

ParseRule return selector,length of rules, index of selector

func ParseRules

func ParseRules(doc interface{}, rule string) (*goquery.Selection, string)

ParseRules parse rules

func RemoveNodes

func RemoveNodes(srcNodes, removeNodes []*html.Node) []*html.Node

RemoveNodes remove nodes

func SortSearchOutput

func SortSearchOutput(so SearchOutput) []string

Types

type Book

type Book struct {
	Tag          string        `json:"tag"`
	Origin       string        `json:"origin"`
	Name         string        `json:"name"`
	Author       string        `json:"author"`
	BookmarkList []interface{} `json:"bookmarkList"`
	ChapterURL   string        `json:"chapterUrl"`
	// BookURL        string            `json:"book_url"`
	CoverURL         string            `json:"coverUrl"`
	Kind             string            `json:"kind"`
	LastChapter      string            `json:"lastChapter"`
	FinalRefreshData UnixTime          `json:"finalRefreshData"`
	NoteURL          string            `json:"noteUrl"`
	Introduce        string            `json:"introduce"`
	ChapterList      []*Chapter        `json:"-"`
	BookSourceInst   *BookSource       `json:"-"`
	Page             *goquery.Document `json:"-"`
}

Book represent a book instance

func NewBookFromURL

func NewBookFromURL(bookURL string) (*Book, error)

NewBookFromURL create new Book instance from URL

func (*Book) GetAuthor

func (b *Book) GetAuthor() string

func (*Book) GetChapterList

func (b *Book) GetChapterList() []*Chapter

func (*Book) GetChapterURL

func (b *Book) GetChapterURL() string

func (*Book) GetIntroduce

func (b *Book) GetIntroduce() string

func (*Book) GetName

func (b *Book) GetName() string

func (Book) String

func (b Book) String() string

func (*Book) UpdateChapterList

func (b *Book) UpdateChapterList(startFrom int) error

type BookSource

type BookSource struct {
	BookSourceGroup       string `json:"bookSourceGroup"`
	BookSourceName        string `json:"bookSourceName"`
	BookSourceURL         string `json:"bookSourceUrl"`
	Enable                bool   `json:"enable"`
	HTTPUserAgent         string `json:"httpUserAgent"`
	RuleBookAuthor        string `json:"ruleBookAuthor"`
	RuleBookContent       string `json:"ruleBookContent"`
	RuleBookName          string `json:"ruleBookName"`
	RuleChapterList       string `json:"ruleChapterList"`
	RuleChapterName       string `json:"ruleChapterName"`
	RuleChapterURL        string `json:"ruleChapterUrl"`
	RuleChapterURLNext    string `json:"ruleChapterUrlNext"`
	RuleContentURL        string `json:"ruleContentUrl"`
	RuleContentURLNext    string `json:"ruleContentUrlNext"`
	RuleCoverURL          string `json:"ruleCoverUrl"`
	RuleFindURL           string `json:"ruleFindUrl"`
	RuleIntroduce         string `json:"ruleIntroduce"`
	RuleSearchAuthor      string `json:"ruleSearchAuthor"`
	RuleSearchCoverURL    string `json:"ruleSearchCoverUrl"`
	RuleSearchKind        string `json:"ruleSearchKind"`
	RuleSearchLastChapter string `json:"ruleSearchLastChapter"`
	RuleSearchList        string `json:"ruleSearchList"`
	RuleSearchName        string `json:"ruleSearchName"`
	RuleSearchNoteURL     string `json:"ruleSearchNoteUrl"`
	RuleSearchURL         string `json:"ruleSearchUrl"`
	SerialNumber          int    `json:"serialNumber"`
	Weight                int    `json:"weight"`
}

BookSource book source structure

func ReadBookSourceFromLocalFileSystem

func ReadBookSourceFromLocalFileSystem(fileName string) (bs []BookSource)

ReadBookSourceFromLocalFileSystem book source is stored in local file, read and parse it

func ReadBookSourceFromURL

func ReadBookSourceFromURL(u string) (bs []BookSource)

ReadBookSourceFromURL book source is stored in a URL, read and parse it

func (*BookSource) SearchBook

func (bs *BookSource) SearchBook(title string) []*Book

SearchBook search book on the book source 例:http://www.gxwztv.com/search.htm?keyword=searchKey&pn=searchPage-1 - ?为get @为post - searchKey为关键字标识,运行时会替换为搜索关键字, - searchPage,searchPage-1为搜索页数,从0开始的用searchPage-1, - page规则还可以写成 {index(第一页), indexSecond(第二页), indexThird(第三页), index-searchPage+1 或 index-searchPage-1 或 index-searchPage} - 要添加转码编码在最后加 |char=gbk - |char=escape 会模拟js escape方法进行编码 如果搜索结果可能会跳到简介页请填写简介页url正则

func (BookSource) String

func (bs BookSource) String() string

type BookSourceCollection

type BookSourceCollection []*BookSource

BookSourceCollection is an array that the element type is a BookSource

type BookSources

type BookSources struct {
	BookSourceCollection
	sync.RWMutex
}

BookSources wrapper for operating array in concurrent environment

func (*BookSources) Add

func (bss *BookSources) Add(bs *BookSource)

Add add a book source to array

func (*BookSources) Clear

func (bss *BookSources) Clear()

Clear remove all elements

func (*BookSources) FindBookSourceByHost

func (bss *BookSources) FindBookSourceByHost(host string) *BookSource

FindBookSourceByHost find the first matched book source

func (*BookSources) FindBookSourcesByHost

func (bss *BookSources) FindBookSourcesByHost(host string) (res BookSources)

FindBookSourcesByHost find all the matched book sources

type Chapter

type Chapter struct {
	BookSourceSite string      `json:"source"`
	BookSourceInst *BookSource `json:"-"`
	Content        string      `json:"content"`
	ChapterTitle   string      `json:"chapter_title"`
	Read           bool        `json:"is_read"`
	ChapterURL     string      `json:"url"`
	Index          int         `json:"index"`
	BelongToBook   *Book
	Page           *goquery.Document `json:"-"`
}

Chapter represent a chapter of a book

func NewChapterFromURL

func NewChapterFromURL(chapterURL string) (*Chapter, error)

func (*Chapter) GetBook

func (c *Chapter) GetBook() *Book

func (*Chapter) GetContent

func (c *Chapter) GetContent() string

func (*Chapter) GetIndex

func (c *Chapter) GetIndex() int

func (*Chapter) GetTitle

func (c *Chapter) GetTitle() string

func (Chapter) String

func (c Chapter) String() string

type SearchOutput

type SearchOutput map[string][]*Book

func SearchBooks

func SearchBooks(title string) SearchOutput

SearchBooks search book from book sources

type SearchResult

type SearchResult struct {
	BookSourceSite string `json:"source"`
	BookTitle      string `json:"name"`
	Author         string `json:"author"`
	BookURL        string `json:"book_url"`
	CoverURL       string `json:"cover_url"`
	Kind           string `json:"kind"`
	LastChapter    string `json:"last_chapter"`
	NoteURL        string `json:"note_url"`
}

SearchResult book search result

type UnixTime

type UnixTime time.Time

UnixTime convert from JSON value to time type

func (UnixTime) MarshalJSON

func (t UnixTime) MarshalJSON() ([]byte, error)

MarshalJSON convert time type to JSON value

func (*UnixTime) UnmarshalJSON

func (t *UnixTime) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON convert from JSON value

Jump to

Keyboard shortcuts

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