excavator

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: MIT Imports: 24 Imported by: 5

README

excavator

How to use

	excH := New(RadicalTypeHanChengPinyin, ActionArgs(RadicalTypeHanChengPinyin, RadicalTypeHanChengBihua, RadicalTypeHanChengBushou))
	e2 := excH.Run()
	if e2 != nil {
		t.Fatal(e2)
	}
	excK := New(RadicalTypeKangXiPinyin, ActionArgs(RadicalTypeKangXiPinyin, RadicalTypeKangXiBihua, RadicalTypeKangXiBushou))
	e1 := excK.Run()
	if e1 != nil {
		t.Fatal(e1)
	}

if want change db address use:

   exc :=New(RadicalTypeHanChengPinyin, DBArgs(#db#))
   or
   exc.SetDB(#db#)

Documentation

Index

Constants

View Source
const (
	UnionMustNotBeNull            = "union must not be null"
	UnparsableNumber              = "unparsable number"
	UnionDoesNotContainNumber     = "union does not contain number"
	DecoderShouldNotReturnFloat64 = "decoder should not return float64"
	UnionDoesNotContainBool       = "union does not contain bool"
	UnionDoesNotContainString     = "union does not contain string"
	UnionDoesNotContainNull       = "union does not contain null"
	UnionDoesNotContainObject     = "union does not contain object"
	UnionDoesNotContainArray      = "union does not contain array"
	CannotHandleDelimiter         = "cannot handle delimiter"
	CannotUnmarshalUnion          = "cannot unmarshal union"
)

const error list ...

View Source
const DefaultMainPage = "http://hy.httpcn.com"
View Source
const HanChengBihua = "/bihua/zi/"
View Source
const HanChengBushou = "/bushou/zi/"
View Source
const HanChengPinyin = "/pinyin/zi/"
View Source
const KangXiBihua = "/bihua/kangxi/"
View Source
const KangXiBushou = "/bushou/kangxi/"
View Source
const KangXiPinyin = "/pinyin/kangxi/"

Variables

This section is empty.

Functions

func DummyRequest added in v0.1.0

func DummyRequest(wd string, qb int) (*http.Request, error)

func HanChengBihuaRequest added in v0.1.0

func HanChengBihuaRequest(wd string, qb string) (*http.Request, error)

func HanChengBushouRequest added in v0.1.0

func HanChengBushouRequest(wd string, qb string) (*http.Request, error)

func HanChengPinyinRequest added in v0.1.0

func HanChengPinyinRequest(wd string, qb string) (*http.Request, error)

func InitMysql

func InitMysql(addr, name, pass string) *xorm.Engine

func InitSqlite3

func InitSqlite3(name string) *xorm.Engine

InitSqlite3 ...

func KangXiBihuaRequest added in v0.1.0

func KangXiBihuaRequest(wd string, qb string) (*http.Request, error)

func KangXiBushouRequest added in v0.1.0

func KangXiBushouRequest(wd string, qb string) (*http.Request, error)

func KangXiPinyinRequest added in v0.1.0

func KangXiPinyinRequest(wd string, qb string) (*http.Request, error)

func StartService added in v0.1.0

func StartService()

func StringClearUp

func StringClearUp(s string) (t string)

StringClearUp ...

func TrimSlash

func TrimSlash(s string) string

TrimSlash ...

func URL

func URL(prefix string, uris ...string) string

URL 拼接地址

Types

type Character

type Character struct {
	Hash                     string   `xorm:"pk hash"`
	PinYin                   []string `xorm:"default() notnull pin_yin"`                     //拼音
	Ch                       string   `xorm:"default() notnull ch"`                          //字符
	Radical                  string   `xorm:"default() notnull radical"`                     //部首
	RadicalStroke            int      `xorm:"default(0) notnull radical_stroke"`             //部首笔画
	Stroke                   int      `xorm:"default() notnull stroke"`                      //总笔画数
	IsKangXi                 bool     `xorm:"default(0) notnull is_kang_xi"`                 //是否康熙字典
	KangXi                   string   `xorm:"default() notnull kang_xi"`                     //康熙
	KangXiStroke             int      `xorm:"default(0) notnull kang_xi_stroke"`             //康熙笔画
	SimpleRadical            string   `xorm:"default() notnull simple_radical"`              //简体部首
	SimpleRadicalStroke      int      `xorm:"default(0) notnull simple_radical_stroke"`      //简体部首笔画
	SimpleTotalStroke        int      `xorm:"default(0) notnull simple_total_stroke"`        //简体笔画
	TraditionalRadical       string   `xorm:"default() notnull traditional_radical"`         //繁体部首
	TraditionalRadicalStroke int      `xorm:"default(0) notnull traditional_radical_stroke"` //繁体部首笔画
	TraditionalTotalStroke   int      `xorm:"default(0) notnull traditional_total_stroke"`   //简体部首笔画
	NameScience              bool     `xorm:"default(0) notnull name_science"`               //姓名学
	WuXing                   string   `xorm:"default() notnull wu_xing"`                     //五行
	Lucky                    string   `xorm:"default() notnull lucky"`                       //吉凶寓意
	Regular                  bool     `xorm:"default(0) notnull regular"`                    //常用
	TraditionalCharacter     []string `xorm:"default() notnull traditional_character"`       //繁体字
	VariantCharacter         []string `xorm:"default() notnull variant_character"`           //异体字
	Comment                  []string `xorm:"default() notnull comment"`                     //解释
}

Character 字符

func NewCharacter added in v0.1.0

func NewCharacter() *Character

func (*Character) BeforeInsert added in v0.1.0

func (c *Character) BeforeInsert()

func (*Character) Clone

func (c *Character) Clone() (char *Character)

Clone ...

func (*Character) InsertOrUpdate added in v0.1.0

func (c *Character) InsertOrUpdate(session *xorm.Session) (i int64, e error)

InsertOrUpdate ...

type CharacterFunc

type CharacterFunc func(character *Character) error

CharacterFunc ...

type ExArgs added in v0.1.0

type ExArgs func(exc *Excavator)

func ActionArgs added in v0.1.0

func ActionArgs(act ...RadicalType) ExArgs

func DBArgs added in v0.1.0

func DBArgs(engine *xorm.Engine) ExArgs

func URLArgs added in v0.1.0

func URLArgs(url string) ExArgs

type Excavator

type Excavator struct {
	Workspace string `json:"workspace"`
	// contains filtered or unexported fields
}

Excavator ...

func New

func New(radicalType RadicalType, args ...ExArgs) *Excavator

New ...

func (*Excavator) DB

func (exc *Excavator) DB() *xorm.Engine

DB ...

func (*Excavator) IsExist

func (exc *Excavator) IsExist(name string) bool

IsExist ...

func (*Excavator) Run

func (exc *Excavator) Run() error

Run ...

func (*Excavator) SetDB

func (exc *Excavator) SetDB(db *xorm.Engine)

SetDB ...

type GrabReader added in v0.1.0

type GrabReader func(wd string, qb ...string) (reader io.ReadCloser, err error)

type ParseFunc

type ParseFunc func(*Character, int, string)

ParseFunc ...

type Query added in v0.1.0

type Query struct {
	// contains filtered or unexported fields
}

func NewQuery added in v0.1.0

func NewQuery(ops ...QueryOptions) *Query

func (*Query) Grab added in v0.1.0

func (q *Query) Grab(radicalType RadicalType) GrabReader

type QueryOptions added in v0.1.0

type QueryOptions func(query *Query)

func CacheOption added in v0.1.0

func CacheOption(cache *net.Cache) QueryOptions

type Radical

type Radical []RadicalUnion

Radical ...

func RadicalReader added in v0.1.0

func RadicalReader(radicalType RadicalType, wd string, qb string) (*Radical, error)

func UnmarshalRadical

func UnmarshalRadical(data []byte) (*Radical, error)

UnmarshalRadical ...

func (*Radical) Marshal

func (r *Radical) Marshal() ([]byte, error)

Marshal ...

type RadicalCharacter

type RadicalCharacter struct {
	Hash       string `json:"hash" xorm:"pk hash"`
	CharType   string `json:"char_type" json:"char_type"`
	Zi         string `json:"zi" xorm:"zi"`
	Alphabet   string `json:"alphabet" xorm:"alphabet"`
	PinYin     string `json:"pinyin" xorm:"pinyin"`
	BiHua      string `json:"bihua" xorm:"bihua"`
	BuShou     string `json:"bushou" xorm:"bushou"`
	TotalBiHua string `json:"total_bihua" xorm:"total_bihua"`
	QiBi       string `json:"qibi" xorm:"qibi"`
	BHNum      string `json:"bh_num" xorm:"bh_num"`
	QBNum      string `json:"qb_num" xorm:"qb_num"`
	Num        string `json:"num" xorm:"num"`
	URL        string `json:"url" xorm:"url"`
}

RadicalCharacter ...

func (*RadicalCharacter) BeforeInsert added in v0.1.0

func (r *RadicalCharacter) BeforeInsert()

func (*RadicalCharacter) GenHash added in v0.1.0

func (r *RadicalCharacter) GenHash() string

type RadicalType added in v0.1.0

type RadicalType int
const (
	RadicalTypeHanChengPinyin RadicalType = iota
	RadicalTypeHanChengBushou
	RadicalTypeHanChengBihua
	RadicalTypeKangXiPinyin
	RadicalTypeKangXiBushou
	RadicalTypeKangXiBihua
)

type RadicalUnion

type RadicalUnion struct {
	String                *string
	RadicalCharacterArray []RadicalCharacter
}

RadicalUnion ...

func (*RadicalUnion) MarshalJSON

func (x *RadicalUnion) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*RadicalUnion) UnmarshalJSON

func (x *RadicalUnion) UnmarshalJSON(data []byte) error

UnmarshalJSON ...

type RequestFunc added in v0.1.0

type RequestFunc func(wd string, qb string) (*http.Request, error)

type RequestType int

type Selenium

type Selenium struct {
	// contains filtered or unexported fields
}

Selenium ...

func NewSelenium

func NewSelenium(path string, port int) *Selenium

NewSelenium ...

func (*Selenium) Get

func (s *Selenium) Get(url string) (w selenium.WebDriver, e error)

Get ...

func (*Selenium) Start

func (s *Selenium) Start()

Start ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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