common

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanHtml

func CleanHtml(str string, depth int) string

清除标签

func ConvertToString

func ConvertToString(src string, srcCode string, tagCode string) string

func DecodeString

func DecodeString(src, charset string) string

func Deprive

func Deprive(s string) string

去除常见转义字符

func Deprive2

func Deprive2(s string) string

去除常见转义字符

func DepriveBreak

func DepriveBreak(s string) string

清除换行--add by lyken 20160512

func DepriveMutiBreak

func DepriveMutiBreak(s string) string

多余的换行--add by lyken 20160819

func EncodeString

func EncodeString(src, charset string) string

func ExtractArticle

func ExtractArticle(html string) string

提取文章页的正文 思路:认为文本节点最长的标签的父标签为文章正文

func Floor

func Floor(f float64, n int) float64

舍去尾数

func GBKToUTF8

func GBKToUTF8(src string) string

func GetHerf

func GetHerf(baseurl string, url string, herf string, mustBase bool) string

网址组合--add by lyken 20160512

func HrefSub

func HrefSub(src string, sub string) string

在原有网址上添加参数--add by lyken 20160901

func MakeUrl

func MakeUrl(path string, schemeAndHost ...string) (string, bool)

@SchemeAndHost https://www.baidu.com @path /search?w=x

func Ping

func Ping(address string, timeoutSecond int) (alive bool, err error, timedelay time.Duration)

func Pinger

func Pinger(address string, timeoutSecond int) error

func ProcessHtml

func ProcessHtml(html string) string

处理html文件--add by lyken 20160512

func SplitCookies

func SplitCookies(cookieStr string) (cookies []*http.Cookie)

cookies字符串转[]*http.Cookie,(如"mt=ci%3D-1_0; thw=cn; sec=5572dc7c40ce07d4e8c67e4879a; v=0;")

func Unicode16ToUTF8

func Unicode16ToUTF8(str string) string

将`{"area":[["quanguo","\u5168\u56fd\u8054\u9500"]]}`转为`{"area":[["quanguo","全国联销"]]}`

func UnicodeToUTF8

func UnicodeToUTF8(str string) string

将"咖啡色|绿色"转为"咖啡色|绿色"

Types

type Form

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

Form is the default form element.

func NewForm

func NewForm(ctx *Context, rule string, u string, form *goquery.Selection, schemeAndHost ...string) *Form

NewForm creates and returns a *Form type.

func (*Form) Action

func (self *Form) Action() string

Action returns the form action URL. The URL will always be absolute.

func (*Form) Click

func (self *Form) Click(button string) bool

Click submits the form by clicking the button with the given name.

func (*Form) Dom

func (self *Form) Dom() *goquery.Selection

Dom returns the inner *goquery.Selection.

func (*Form) Input

func (self *Form) Input(name, value string) *Form

Input sets the value of a form field.

func (*Form) Inputs

func (self *Form) Inputs(kv map[string]string) *Form

Input sets the value of a form field.

func (*Form) Method

func (self *Form) Method() string

Method returns the form method, eg "GET" or "POST" or "POST-M".

func (*Form) Submit

func (self *Form) Submit() bool

Submit submits the form. Clicks the first button in the form, or submits the form without using any button when the form does not contain any buttons.

Jump to

Keyboard shortcuts

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