Documentation ¶
Index ¶
- func ParseRule(rule string) (string, int, int)
- func ParseRules(doc interface{}, rule string) (*goquery.Selection, string)
- func RemoveNodes(srcNodes, removeNodes []*html.Node) []*html.Node
- func SortSearchOutput(so SearchOutput) []string
- type Book
- type BookSource
- type BookSourceCollection
- type BookSources
- type Chapter
- type SearchOutput
- type SearchResult
- type UnixTime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseRules ¶
ParseRules parse rules
func RemoveNodes ¶
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 ¶
NewBookFromURL create new Book instance from URL
func (*Book) GetChapterList ¶
func (*Book) GetChapterURL ¶
func (*Book) GetIntroduce ¶
func (*Book) UpdateChapterList ¶
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) 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 (*Chapter) GetContent ¶
type SearchOutput ¶
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 ¶
UnixTime convert from JSON value to time type
func (UnixTime) MarshalJSON ¶
MarshalJSON convert time type to JSON value
func (*UnixTime) UnmarshalJSON ¶
UnmarshalJSON convert from JSON value