spider

package
v0.0.0-...-f76bd4e Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultUserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36"

Variables

View Source
var (
	ErrInitialBookID = errors.New("illegal book id, it should exceed 0")
	ErrRetryTimes    = errors.New("illegal retry times, it should exceed 0")
	ErrThreadCounts  = errors.New("illegal download thread counts, it should exceed 0")
)
View Source
var AliyunConfig = &AliYunConfig{}

Functions

func BindDownloadArgs

func BindDownloadArgs(command *cobra.Command, config *Config)

BindDownloadArgs will bind the download arguments to cobra command.

func LoadConfig

func LoadConfig(c *Config, aliC *AliYunConfig)

func NewAliyunDrive

func NewAliyunDrive(c *Client, aliConfig *AliYunConfig) *aliyundrive.AliYunDrive

func NewCookieJar

func NewCookieJar(path string) (http.CookieJar, error)

NewCookieJar would create a cookie jar instance. It supports auto saving policy.

func ResolveAliyunDrive

func ResolveAliyunDrive(client *Client, shareUrl string, sharePwd string, formats ...string) ([]string, error)

func ValidateDownloadConfig

func ValidateDownloadConfig(config *Config)

ValidateDownloadConfig would print the final download config table.

Types

type AliYunConfig

type AliYunConfig struct {
	RefreshToken string
}

type Client

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

func NewClient

func NewClient(config *Config) *Client

NewClient would create a client with persisted cookie file.

func (*Client) CheckRedirect

func (c *Client) CheckRedirect(checkFunc func(req *http.Request, via []*http.Request) error)

CheckRedirect add extra check func for 302 or 301 redirect.

func (*Client) FormPost

func (c *Client) FormPost(link, referer string, form Form) (*http.Response, error)

FormPost would post with form-url-encoded.

func (*Client) Get

func (c *Client) Get(link, referer string, params ...*Query) (*http.Response, error)

Get would perform http get.

func (*Client) Retry

func (c *Client) Retry(f func() error) (err error)

type Config

type Config struct {
	Website       string        // The website for talebook.
	Username      string        // The login user.
	Password      string        // The password for login user.
	DownloadPath  string        // Use the executed directory as the default download path.
	CookieFile    string        // The cookie file to use in this download progress.
	ProgressFile  string        // The progress file serving the remaining book id.
	InitialBookID int           // The book id start to download.
	Formats       []string      // The file formats you want to download
	Timeout       time.Duration // The request timeout for a single request.
	Retry         int           // The maximum retry times for a timeout request.
	UserAgent     string        // The user agent for the download request.
	Rename        bool          // Rename the file by using book ID.
	Thread        int           // The number of download thread.
	Debug         bool          // Enable debug log.
}

func NewConfig

func NewConfig() *Config

NewConfig will return a default blank config.

type Field

type Field struct {
	Key   string
	Value string
}

type Form

type Form []Field

Form used for post

type Query

type Query struct {
	Key   string
	Value string
}

Query used for get

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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