web

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Attr AttrType = "attr" //属性
	Html AttrType = "html" //html
	Text AttrType = "text" //文本

	One  Multiple = "one"  //一个
	Many Multiple = "many" //多个
	Obj  Multiple = "grab" //新对象
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AR

type AR struct {
	AttrType AttrType `json:"attr_type"` //属性类型
	AttrName string   `json:"attr_name"` //属性值
}

LV 用于列表页

type AttrType

type AttrType string //属性类型

type Doc

type Doc struct {
	*goquery.Document
	Err error
}

func NewDoc

func NewDoc(doc *goquery.Document) *Doc

func NewDocByStr

func NewDocByStr(str string) *Doc

func NewDocErr added in v1.0.1

func NewDocErr(doc *goquery.Document, err error) *Doc

func (*Doc) Clear

func (obj *Doc) Clear()

func (*Doc) Find

func (obj *Doc) Find(selector string) *Sel

Find 根据规则查找

func (*Doc) FindMany

func (obj *Doc) FindMany(val []FO) (retMap KV, err error)

FindMany 获取多个匹配的值,返回键值对

func (*Doc) FindOneValues

func (obj *Doc) FindOneValues(val FO) (ret []string, err error)

FindOneValues 获取匹配的值数组

type FM

type FM struct {
	Key string `json:"key"`
	FO  `json:"eo"`
}

type FO

type FO struct {
	Selector string             `json:"selector"` //选择器
	AttrType `json:"attr_type"` //属性类型
	AttrName string             `json:"attr_name"` //属性值
}

type Grab

type Grab struct {
}

func NewGrab

func NewGrab() *Grab

func (*Grab) Fetch

func (obj *Grab) Fetch(url string) *Doc

Fetch 请求url获取文档对象

type KV

type KV map[string]string

type Multiple

type Multiple string //数量类型:一个或多个

type Sel

type Sel struct {
	*goquery.Selection
	Err error
}

func NewSel

func NewSel(sel *goquery.Selection) *Sel

func (*Sel) Clear

func (obj *Sel) Clear()

func (*Sel) Foreach

func (obj *Sel) Foreach(f func(int, *goquery.Selection)) *Sel

Foreach 循环

func (*Sel) List

func (obj *Sel) List(v AR) (ret []string, err error)

List 获取列表 List(LV{Attr, "href"})

func (*Sel) ListManyAttr

func (obj *Sel) ListManyAttr(val []AR) (ret []map[string]string, err error)

ListManyAttr 获取列表

ListManyAttr([]AR{
  {Attr, "href"}
  {Attr, "href"}
})

Jump to

Keyboard shortcuts

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