Concurrent

package
v0.0.0-...-52d5af9 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(url string) (resp gorequest.Response, body string, err []error)

简单写了个下载器

func ParseList

func ParseList(body string, info ArticleInfo, taskC chan requests, resultC chan interface{})

基于xpath解析列表页

func SaveItem

func SaveItem(item interface{})

engine -->pipline, pipline里可以处理返回结果

Types

type ArticleInfo

type ArticleInfo struct {
	Type int
	// contains filtered or unexported fields
}

定义的item 结果体

type Engine

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

func CreateEngine

func CreateEngine(workChan chan requests, maxPoolSize int, resultC chan interface{}) *Engine

创建引擎

func InitEngine

func InitEngine(maxPoolSize, maxItemSize int) (e *Engine)

引擎初始化

func (*Engine) GetResult

func (e *Engine) GetResult() chan interface{}

获取结果的chan

func (*Engine) Run

func (e *Engine) Run()

引擎run起来

func (*Engine) StartRequest

func (e *Engine) StartRequest(startUrl string, call func(body string, info ArticleInfo, taskC chan requests, resultC chan interface{})) *Engine

仿 scrapy写了个start_request

type Pool

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

func NewPool

func NewPool(maxNum int) *Pool

func (*Pool) Add

func (p *Pool) Add()

func (*Pool) Done

func (p *Pool) Done()

func (*Pool) Wait

func (p *Pool) Wait()

type Schduler

type Schduler interface {
	// contains filtered or unexported methods
}

调度器的接口

Jump to

Keyboard shortcuts

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