bkhtml

package
v0.0.0-...-54886de Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilterOperation_GetContent     int = 1 // 取得目標標籤內文
	FilterOperation_GetSubToken    int = 2 // 取得目標標籤內的子標籤
	FilterOperation_GetSubcContent int = 3 // 取得目標標籤內的子內文
)

Filter Operation

Variables

This section is empty.

Functions

func AttrCompare

func AttrCompare(targetAttr html.Attribute, token *html.Token) bool

目標 attr 是否存在 token 內

func AttrsCompare

func AttrsCompare(targetAttrs []html.Attribute, token *html.Token) bool

目標 attrs 是否全部都在目標內

func GetAttr

func GetAttr(attrKey string, attrs []html.Attribute) string

取得節點附加參數

@params attrKey 附加參數關鍵字

@params []html.Attribute 附加參數列表

@return string 附加參數資料, PS: 預設為空字串

func GetContext

func GetContext(node *TokenObjSub) string

取得所有子物件內文

@params *TokenObjSub 起始解點

@return string 內文

func GetWebPackage

func GetWebPackage(url string) (map[string][]string, []byte, error)

取得網頁 @parame string 網址 @retrun map[string]string Http Header @return []byte Http Body @return error 錯誤回傳

func HtmlLoop

func HtmlLoop(tokenizer *html.Tokenizer, filter map[types.TokenTypeName][]*FilterObj)

func HtmlLoopFilter

func HtmlLoopFilter(body io.Reader, selfClosingTagToken []string, filterMap map[types.TokenTypeName][]*FilterObjnewSub, pageFix func(nodeDepth int, next, current, previous **TokenObjSub) (int, bool))

func HtmlLoopFilterDefaultClose

func HtmlLoopFilterDefaultClose(body io.Reader, filterMap map[types.TokenTypeName][]*FilterObjnewSub, pageFix func(nodeDepth int, next, current, previous **TokenObjSub) (int, bool))

func HtmlLoopFilterOne

func HtmlLoopFilterOne(tokenizer *html.Tokenizer, filterMap map[types.TokenTypeName][]*FilterObj)

func HtmlLoopFilterUnFix

func HtmlLoopFilterUnFix(body io.Reader, selfClosingTagToken []string, filterMap map[types.TokenTypeName][]*FilterObjnewSub)

func IsTextEnd

func IsTextEnd(text string) bool

func LoadHttpRespont

func LoadHttpRespont(resp *http.Response) (map[string][]string, []byte, error)

func SetDefaultClient

func SetDefaultClient()

Types

type FilterObj

type FilterObj struct {
	FiltAttrs  []html.Attribute // 標籤篩選條件
	Res        []html.Token     // 標籤結構
	SubRes     []html.Token     // 標籤結構
	Content    []string         // 標籤內文
	SubContent []string         // 標籤內文
	Operation  []int            // 控制選項 暫時用數字處理
}

type FilterObjnewSub

type FilterObjnewSub struct {
	FiltAttrs []html.Attribute // 標籤篩選條件
	Res       []*TokenObjSub   // 標籤結構
	Operation []int            // 控制選項 暫時用數字處理
}

取得符合的底下所有仔物件

type FindOption

type FindOption struct {
	Key      string
	Value    string
	MaxDepth int
	IsPrint  bool
}

type HtmlLoopTool

type HtmlLoopTool struct {
	SelfClosingTagToken []string
}

func (HtmlLoopTool) HtmlLoopFilterLevelSub

func (self HtmlLoopTool) HtmlLoopFilterLevelSub(tokenizer *html.Tokenizer, filterMap map[types.TokenTypeName][]*FilterObjnewSub, pageFix func(nodeDepth int, next, current, previous **TokenObjSub) (int, bool))

建立全物件索引, 並索引符合條件的物件

@params *html.Tokenizer 頁面資料

@params map[types.TokenTypeName][]*FilterObjnewSub 塞選器物件

@params func(nodeDepth int, next, current, previous **TokenObjSub) (int, bool) 頁面修正方法

type HtmlTree

type HtmlTree struct {
	Root *html.Node
}

type TokenObjSub

type TokenObjSub struct {
	NodeDepth int
	NodeId    int
	Previous  *TokenObjSub   // 前一個
	Res       *html.Token    // 當前
	SubRes    []*TokenObjSub // 子標籤結構
}

type WebInfo

type WebInfo interface {
	Url() string
}

Jump to

Keyboard shortcuts

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