lagou

package
v0.0.0-...-65a5f2b Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2017 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	UserAgent       string `json:"userAgent"`       // recommend UA from Chrome
	RequestTimeout  int    `json:"requestTimeout"`  // seconds
	RequestInterval int    `json:"requestInterval"` // milliseconds
	Search          struct {
		City     string   `json:"city"`     // the city
		Keywords []string `json:"keywords"` // how to search from lagou
		Company  struct {
			ExcludeID []int `json:"excludeID"` // must exclude CompanyID
		} `json:"company"`
		Position struct {
			ExcludeID []int `json:"excludeID"` // must exclude PositionID
			Filter    struct {
				Include []string `json:"include"` // must include words
				Exclude []string `json:"exclude"` // must exclude words
			} `json:"filter"`
			Salary struct {
				Min int `json:"min"` // min salary
				Max int `json:"max"` // max salary
			} `json:"salary"`
		} `json:"position"`
	} `json:"search"`
	Output struct {
		Files struct {
			JSON string `json:"json"`
		} `json:"files"`
		HTTP struct {
			Port int `json:"port"`
		} `json:"http"`
	} `json:"output"`
}

Config the config.json file structure

func (*Config) ReadConfig

func (c *Config) ReadConfig(filename string) error

ReadConfig Read the filename path file, and parse to Config.

type Filter

type Filter struct {
	Company struct {
		ExcludeID map[int]bool // must exclude CompanyID
	}
	Position struct {
		ExcludeID map[int]bool // must exclude PositionID
		Filter    struct {
			Include []string // must include words
			Exclude []string // must exclude words
		}
		Salary struct {
			Min int // min salary
			Max int // max salary
		}
	}
}

Filter lagou jobs filter

type Request

type Request struct {
	RequestTimeout  time.Duration
	RequestInterval time.Duration
}

Request defines http request config

type ResultCompany

type ResultCompany struct {
	CompanyID       int              `json:"companyID"`
	CompanyName     string           `json:"companyName"`
	CompanyFullName string           `json:"companyFullName"`
	CompanyURL      string           `json:"companyURL"`
	Positions       []ResultPosition `json:"positions"`
}

ResultCompany defines structure of lagou company result

type ResultPosition

type ResultPosition struct {
	PositionID   int    `json:"positionID"`
	PositionName string `json:"positionName"`
	PositionURL  string `json:"positionURL"`
	Salary       string `json:"salary"`
	CreateTime   string `json:"createTime"`
}

ResultPosition defines structure of lagou position result

type Results

type Results struct {
	Companies []ResultCompany `json:"companies"`
}

Results defines all lagou results

type Spider

type Spider struct {
	Config
	Filter
	Request

	Cookies string
	// contains filtered or unexported fields
}

Spider defines lagou spider main body

func New

func New(configPath string) (*Spider, error)

New returns a Spider instance

func (*Spider) GetCookies

func (s *Spider) GetCookies() error

GetCookies fetch and set cookies from a http request.

func (Spider) SearchPositionMap

func (s Spider) SearchPositionMap(city, keyword string) (mobile.PositionMap, error)

SearchPositionMap search all positions via city and keyword, returns a PositionMap.

func (Spider) SearchPositionMaps

func (s Spider) SearchPositionMaps(city string, keywords ...string) (mobile.PositionMap, error)

SearchPositionMaps search all positions via city and some keywords, returns a PositionMap.

func (*Spider) Start

func (s *Spider) Start() error

Start start the searching jobs

func (*Spider) Stop

func (s *Spider) Stop()

Stop stop the searching jobs

Directories

Path Synopsis
entity

Jump to

Keyboard shortcuts

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