common

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BiliDomain = iota + 101
	BiliSign   // 签到
	BiliBCount // 获取 B 币数量
)

B 站相关任务

View Source
const (
	HPIDomain = iota + 201
	HPISign   // 签到
)

黑客派相关任务

View Source
const (
	STGDomain = iota + 301
	STGSign   // 签到
)

Go 语言中文网相关任务

View Source
const (
	V2exDomain = iota + 401
	V2exSign   // 签到
)

v2ex 相关任务

View Source
const (
	SignIn = "sign in"
	Verify = "verify"

	Query = "query"

	GetToken = "get token"
)

访问阶段定义

Variables

View Source
var (
	ErrorAuthFailed   = errors.New("auth failed")
	ErrorLogNotFound  = errors.New("log not found")
	ErrorSignInFailed = errors.New("sign in failed")
	ErrorDateNotMatch = errors.New("date not match")
)

验证过程的错误

View Source
var (
	ErrorUnsupportedDomain = errors.New("unsupported domain")
	ErrorUnsupportedType   = errors.New("unsupported type")
)

其他错误

View Source
var (
	RetryNumber   = 3
	RetryInterval = 100 * time.Millisecond
)

重试配置

View Source
var TypeMap = map[int]string{
	BiliSign:   "B站签到",
	BiliBCount: "B币查询",
	HPISign:    "黑客派签到",
	STGSign:    "Go语言中文网签到",
	V2exSign:   "v2ex签到",
}

TypeMap 任务字符串描述

Functions

func NewJar

func NewJar(key, domain, u string) *cookiejar.Jar

NewJar 从给定 cookie 字符串构造 jar

func ParseBody

func ParseBody(client *http.Client, u string, v interface{}) error

ParseBody 解析 body 中的 json 数据到 v

func ParseBodyHeader

func ParseBodyHeader(client *http.Client, u string, header map[string]string) error

ParseBodyHeader 用于访问一个 url, 并且可以指定 http.Request header

func ParseBodyPost

func ParseBodyPost(client *http.Client, u string, reader io.Reader, v interface{}) error

ParseBodyPost 可以指定 http.Request body

func ParseRawBody

func ParseRawBody(client *http.Client, u string) ([]byte, error)

ParseRawBody 读取 body 为 []byte

func ResolveCookies

func ResolveCookies(raw, domain string) []*http.Cookie

ResolveCookies 从字符构造 http.Cookie

func VerifyDate

func VerifyDate(raw string) error

VerifyDate 验证指定时间字符串与当前时间的日期是否相同

Types

This section is empty.

Jump to

Keyboard shortcuts

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