Documentation ¶
Index ¶
- Constants
- Variables
- func AutoGetHtmlEncode(html string, encode string) string
- func DecodeMessage(b []byte) (*nsq.Message, error)
- func DefaultPipelines(i IItem)
- func Host(url string) (string, error)
- func NewKafkaConsumer(opt *Consumer) *kafkaConsumer
- func NewNsqConsumer(opt *Consumer) *nsqConsumer
- func NewRedisCluster(ips []string, password string) *redis.ClusterClient
- func Once(f func())
- func Regex(html, rex string) pie.Strings
- func Validated(s interface{}) bool
- type AbuyunProxy
- type Auth
- type Broker
- type BrowserName
- type Channel
- type Consumer
- type Crawler
- func (t *Crawler) Do() (*Crawler, error)
- func (t *Crawler) Html() String
- func (t *Crawler) SetCookies(cookie *http.Cookie) *Crawler
- func (t *Crawler) SetHeader(header requests.Header) *Crawler
- func (t *Crawler) SetMethod(method string) *Crawler
- func (t *Crawler) SetParser(i IParser) *Crawler
- func (t *Crawler) SetPipelines(cb func(i IItem)) *Crawler
- func (t *Crawler) SetPostJson(json String) *Crawler
- func (t *Crawler) SetTimeOut(duration time.Duration) *Crawler
- func (t *Crawler) Validate() (err error)
- type DefaultClient
- func (d *DefaultClient) Get(url String, args ...interface{}) (resp *requests.Response, err error)
- func (d *DefaultClient) PostBinary(url, js String, args ...interface{}) (*requests.Response, error)
- func (d *DefaultClient) PostJson(url, js String, args ...interface{}) (*requests.Response, error)
- func (d *DefaultClient) SetHeaders(header requests.Header)
- func (d *DefaultClient) SetTimeOut(duration time.Duration)
- type DefaultParser
- type Feeds
- type G
- type GoQueryAttribParser
- type GoQueryParser
- type GoQueryTextParser
- type IBroker
- type IClient
- type IConsumer
- type IItem
- type IParser
- type IProxy
- type IProxyQueue
- type JsonParser
- type KafkaBroker
- type Map
- func (m *Map) Add(v interface{})
- func (m *Map) Contains(s string) bool
- func (m *Map) Dumps() (String, error)
- func (m *Map) Empty() bool
- func (m *Map) Get(k String) interface{}
- func (m *Map) Items() map[String]interface{}
- func (m *Map) Load(b []byte) error
- func (m *Map) Pop(s String) interface{}
- func (m *Map) Size() int
- type MixedParser
- type MongoClient
- func (m *MongoClient) Add(doc bongo.Document) error
- func (m *MongoClient) Collection(col string) *MongoClient
- func (m *MongoClient) Count(m2 bson.M) (int, error)
- func (m *MongoClient) Del(doc bongo.Document)
- func (m *MongoClient) Find(query interface{}) *bongo.ResultSet
- func (m *MongoClient) FindOne(query interface{}, result interface{}) error
- func (m *MongoClient) Init()
- func (m *MongoClient) Pipe(args ...bson.M) *mgo.Pipe
- func (m *MongoClient) Remove(query bson.M) bool
- type Next
- type NsqBroker
- type Options
- type Page
- type Pages
- type ParserResult
- type Pattern
- type ProxyClient
- func (p *ProxyClient) Get(url String, args ...interface{}) (resp *requests.Response, err error)
- func (p *ProxyClient) PostJson(url, js String, args ...interface{}) (*requests.Response, error)
- func (p *ProxyClient) SetHeaders(header requests.Header)
- func (p *ProxyClient) SetTimeOut(duration time.Duration)
- type ProxyIp
- type ProxyQueue
- type R
- type RedisBroker
- type RedisClient
- func (r *RedisClient) Existed(key string) bool
- func (r *RedisClient) Expire(key string, duration time.Duration)
- func (r *RedisClient) Incr(key string) int64
- func (r *RedisClient) Instance() *redis.Client
- func (r *RedisClient) LLen(key string) (int64, error)
- func (r *RedisClient) Lpop(key string) (string, error)
- func (r *RedisClient) Lpush(key string, val interface{})
- func (r *RedisClient) MaxKeyCount(key string, max int) bool
- func (r *RedisClient) Pipelines(fn func(pipeliner redis.Pipeliner) error) error
- func (r *RedisClient) Publish(channels string, msg interface{}) error
- func (r *RedisClient) SCard(key string) (int64, error)
- func (r *RedisClient) SIsMember(key, id string) bool
- func (r *RedisClient) SPopN(key string, count int64) ([]string, error)
- func (r *RedisClient) Sorted(key string, sort *redis.Sort) *redis.StringSliceCmd
- func (r *RedisClient) Sub(channels ...string) <-chan *redis.Message
- type RedisConsumer
- type RegexItem
- type RegexItems
- type RegexParser
- type Requests
- func (r *Requests) Do() (resp *requests.Response, err error)
- func (r *Requests) Json(js String) *Requests
- func (r *Requests) SetCookies(cookie *http.Cookie) *Requests
- func (r *Requests) SetHeader(headers requests.Header) *Requests
- func (r *Requests) SetMethod(method string) *Requests
- func (r *Requests) SetTimeOut(timeout time.Duration) *Requests
- type Response
- type String
- type StringList
- type T
- type Url
- type WaitGroupWrap
- type XmlItem
Constants ¶
View Source
const ( ParserNotFound = iota RequestsError )
View Source
const ( GET = "get" POST = "post" POSTJSON = "post-json" DefaultTimeOut time.Duration = 1 )
View Source
const (
ProxIpMaxExpiredTime float64 = 5
)
View Source
const (
TimeFormat = "2006-01-02 15:04:05"
)
Variables ¶
View Source
var (
Stop = make(chan os.Signal, 1)
)
Functions ¶
func AutoGetHtmlEncode ¶
func DecodeMessage ¶
func DefaultPipelines ¶
func DefaultPipelines(i IItem)
func NewKafkaConsumer ¶
func NewKafkaConsumer(opt *Consumer) *kafkaConsumer
func NewNsqConsumer ¶
func NewNsqConsumer(opt *Consumer) *nsqConsumer
func NewRedisCluster ¶
func NewRedisCluster(ips []string, password string) *redis.ClusterClient
Types ¶
type AbuyunProxy ¶
func NewAbutunProxy ¶
func NewAbutunProxy(appid, secret, proxyServer string) *AbuyunProxy
func (AbuyunProxy) Get ¶
func (p AbuyunProxy) Get() IProxy
func (AbuyunProxy) Init ¶
func (p AbuyunProxy) Init()
func (AbuyunProxy) ProxyClient ¶
func (p AbuyunProxy) ProxyClient() (*http.Client, IProxy)
func (AbuyunProxy) Put ¶
func (p AbuyunProxy) Put(proxy IProxy)
type Broker ¶
type Broker struct { NsqBroker *NsqBroker `yaml:"nsq" json:"nsq_broker"` RedisBroker *RedisBroker `yaml:"redis" json:"redis_broker"` KafkaBroker *KafkaBroker `yaml:"kafka" json:"kafka_broker"` Nsq bool `yaml:"__nsq" json:"nsq"` Rds bool `yaml:"__rds" json:"rds"` Kfk bool `yaml:"__kafka" json:"kafka"` }
type BrowserName ¶
type BrowserName String
type Channel ¶
type Channel struct { Title string `xml:"title"` Link string `xml:"link"` Description string `xml:"description"` LastBuildDate string `xml:"lastBuildDate"` Item []*XmlItem `xml:"item"` sync.RWMutex }
func (*Channel) AddLastPubTime ¶
type Consumer ¶
type Consumer struct { Nsq *nsqConsumer Redis *RedisConsumer Kafka *kafkaConsumer Limit int }
type Crawler ¶
type Crawler struct { Request *Requests `validate:"required"` Cb func(i IItem) Parser IParser `validate:"required"` Item IItem `validate:"required"` Ip IProxy ProxyQueue IProxyQueue sync.RWMutex // contains filtered or unexported fields }
func NewCrawler ¶
func NewProxyCrawler ¶
func (*Crawler) SetPipelines ¶
func (*Crawler) SetPostJson ¶
type DefaultClient ¶
func (*DefaultClient) Get ¶
func (d *DefaultClient) Get(url String, args ...interface{}) (resp *requests.Response, err error)
func (*DefaultClient) PostBinary ¶
func (d *DefaultClient) PostBinary(url, js String, args ...interface{}) (*requests.Response, error)
func (*DefaultClient) PostJson ¶
func (d *DefaultClient) PostJson(url, js String, args ...interface{}) (*requests.Response, error)
func (*DefaultClient) SetHeaders ¶
func (d *DefaultClient) SetHeaders(header requests.Header)
func (*DefaultClient) SetTimeOut ¶
func (d *DefaultClient) SetTimeOut(duration time.Duration)
type DefaultParser ¶
func (*DefaultParser) Load ¶
func (r *DefaultParser) Load(i IItem)
func (*DefaultParser) Validate ¶
func (r *DefaultParser) Validate() bool
type Feeds ¶
type GoQueryAttribParser ¶
type GoQueryAttribParser struct { DefaultParser Result *StringList // contains filtered or unexported fields }
func A ¶
func A(pattern _A, attrib string) *GoQueryAttribParser
func (*GoQueryAttribParser) Encode ¶
func (g *GoQueryAttribParser) Encode(s string) IParser
func (*GoQueryAttribParser) Validate ¶
func (g *GoQueryAttribParser) Validate() bool
type GoQueryParser ¶
type GoQueryParser struct { Html string DefaultParser // contains filtered or unexported fields }
func NewGoQueryParser ¶
func NewGoQueryParser(pattern G) *GoQueryParser
func (*GoQueryParser) Encode ¶
func (g *GoQueryParser) Encode(s string) IParser
type GoQueryTextParser ¶
type GoQueryTextParser struct { Html string DefaultParser // contains filtered or unexported fields }
func NewGoQueryTextParser ¶
func NewGoQueryTextParser(pattern T) *GoQueryTextParser
func (*GoQueryTextParser) Encode ¶
func (g *GoQueryTextParser) Encode(s string) IParser
type IClient ¶
type IClient interface { Get(url String, args ...interface{}) (*requests.Response, error) PostJson(url, js String, args ...interface{}) (*requests.Response, error) SetTimeOut(duration time.Duration) SetHeaders(header requests.Header) }
func NewDefaultClient ¶
func NewDefaultClient() IClient
type IProxyQueue ¶
type JsonParser ¶
type JsonParser struct { DefaultParser Html string // contains filtered or unexported fields }
func NewJsonParser ¶
func NewJsonParser() *JsonParser
func (*JsonParser) Encode ¶
func (r *JsonParser) Encode(s string) IParser
type KafkaBroker ¶
type KafkaBroker struct { Addrs []string `json:"addrs"` Topic string `json:"topic"` sync.WaitGroup // contains filtered or unexported fields }
func NewKafkaBroker ¶
func NewKafkaBroker(addrs []string, topic string) *KafkaBroker
func (*KafkaBroker) Add ¶
func (k *KafkaBroker) Add(item IItem) bool
func (*KafkaBroker) Init ¶
func (k *KafkaBroker) Init()
type MixedParser ¶
type MixedParser struct { DefaultParser // contains filtered or unexported fields }
func NewMixdParser ¶
func NewMixdParser(pattern Pattern) *MixedParser
func (*MixedParser) Encode ¶
func (m *MixedParser) Encode(s string) IParser
type MongoClient ¶
type MongoClient struct {
// contains filtered or unexported fields
}
func NewMongoClient ¶
func NewMongoClient(config []*bongo.Config) *MongoClient
func (*MongoClient) Collection ¶
func (m *MongoClient) Collection(col string) *MongoClient
func (*MongoClient) Del ¶
func (m *MongoClient) Del(doc bongo.Document)
删除单条doc, 如果doc 包含BeforeDelete 和 AfterDeleteHook 则触发.
func (*MongoClient) Find ¶
func (m *MongoClient) Find(query interface{}) *bongo.ResultSet
func (*MongoClient) FindOne ¶
func (m *MongoClient) FindOne(query interface{}, result interface{}) error
func (*MongoClient) Init ¶
func (m *MongoClient) Init()
func (*MongoClient) Pipe ¶
func (m *MongoClient) Pipe(args ...bson.M) *mgo.Pipe
type Next ¶
type NsqBroker ¶
type NsqBroker struct { Urls []string `json:"urls" validate:"required"` Topic string `json:"topic" validate:"required"` Channel string `json:"channel" validate:"required"` sync.RWMutex // contains filtered or unexported fields }
func NewNsqBroker ¶
type Options ¶
type Options struct { Version string `json:"version"` AppName string `yaml:"kind" json:"app_name"` Pages *Pages `json:"pages"` Broker *Broker `json:"broker"` Consumer *Consumer `json:"consumer"` }
func NewOptions ¶
type ParserResult ¶
type ParserResult struct { Key string `bson:"key"` Value interface{} `bson:"value"` }
func NewPr ¶
func NewPr(key string, value interface{}) *ParserResult
func (*ParserResult) String ¶
func (p *ParserResult) String() string
type ProxyClient ¶
func (*ProxyClient) Get ¶
func (p *ProxyClient) Get(url String, args ...interface{}) (resp *requests.Response, err error)
func (*ProxyClient) PostJson ¶
func (p *ProxyClient) PostJson(url, js String, args ...interface{}) (*requests.Response, error)
func (*ProxyClient) SetHeaders ¶
func (p *ProxyClient) SetHeaders(header requests.Header)
func (*ProxyClient) SetTimeOut ¶
func (p *ProxyClient) SetTimeOut(duration time.Duration)
type ProxyIp ¶
type ProxyIp struct { Host string `json:"host"` Port int `json:"port"` CreateTime time.Time `json:"create_time"` Failures int `json:"failures"` Used int `json:"used"` Available bool `json:"available"` sync.RWMutex }
func NewProxyIp ¶
type ProxyQueue ¶
type ProxyQueue struct { Queue chan IProxy PullUrl string MaxCaps int Sleep time.Duration sync.RWMutex }
func (*ProxyQueue) Get ¶
func (q *ProxyQueue) Get() IProxy
func (*ProxyQueue) Init ¶
func (q *ProxyQueue) Init()
func (*ProxyQueue) ProxyClient ¶
func (p *ProxyQueue) ProxyClient() (*http.Client, IProxy)
func (*ProxyQueue) Put ¶
func (q *ProxyQueue) Put(ip IProxy)
type RedisBroker ¶
type RedisBroker struct { Host string `json:"host" validate:"required"` Password string `json:"password"` Db int `json:"db"` Topic string `json:"Topic" validate:"required"` WaitGroupWrap // contains filtered or unexported fields }
func NewRedisBroker ¶
func NewRedisBroker(host, password, topic string, db int) *RedisBroker
func (*RedisBroker) Add ¶
func (r *RedisBroker) Add(item IItem) bool
func (*RedisBroker) Init ¶
func (r *RedisBroker) Init()
type RedisClient ¶
type RedisClient struct {
// contains filtered or unexported fields
}
func (*RedisClient) Existed ¶
func (r *RedisClient) Existed(key string) bool
func (*RedisClient) Incr ¶
func (r *RedisClient) Incr(key string) int64
func (*RedisClient) Instance ¶
func (r *RedisClient) Instance() *redis.Client
func (*RedisClient) Lpush ¶
func (r *RedisClient) Lpush(key string, val interface{})
func (*RedisClient) MaxKeyCount ¶
func (r *RedisClient) MaxKeyCount(key string, max int) bool
func (*RedisClient) Pipelines ¶
func (r *RedisClient) Pipelines(fn func(pipeliner redis.Pipeliner) error) error
func (*RedisClient) Publish ¶
func (r *RedisClient) Publish(channels string, msg interface{}) error
func (*RedisClient) SIsMember ¶
func (r *RedisClient) SIsMember(key, id string) bool
func (*RedisClient) Sorted ¶
func (r *RedisClient) Sorted(key string, sort *redis.Sort) *redis.StringSliceCmd
type RedisConsumer ¶
type RedisConsumer struct { Host string Password string Db int Topic string Limit int // contains filtered or unexported fields }
func NewRedisConsumer ¶
func NewRedisConsumer(opt *Consumer) *RedisConsumer
func (*RedisConsumer) HandleMessage ¶
func (r *RedisConsumer) HandleMessage(msg *nsq.Message) (err error)
func (*RedisConsumer) Init ¶
func (r *RedisConsumer) Init()
func (*RedisConsumer) Run ¶
func (r *RedisConsumer) Run()
func (*RedisConsumer) SetHandler ¶
func (r *RedisConsumer) SetHandler(handler nsq.Handler) IConsumer
type RegexItems ¶
type RegexItems []RegexItem
func (RegexItems) First ¶
func (r RegexItems) First() string
func (RegexItems) Val ¶
func (r RegexItems) Val() pie.Strings
type RegexParser ¶
type RegexParser struct { Html string Pattern String DefaultParser // contains filtered or unexported fields }
func NewRegexParser ¶
func NewRegexParser(pattern R) *RegexParser
func (*RegexParser) Encode ¶
func (r *RegexParser) Encode(s string) IParser
type Requests ¶
func NewRequest ¶
type StringList ¶
func NewStringList ¶
func NewStringList() *StringList
func (*StringList) Add ¶
func (l *StringList) Add(item interface{})
func (*StringList) Contains ¶
func (l *StringList) Contains(s string) bool
func (*StringList) Dumps ¶
func (l *StringList) Dumps() (String, error)
func (*StringList) Empty ¶
func (l *StringList) Empty() bool
func (*StringList) Items ¶
func (l *StringList) Items() pie.Strings
func (*StringList) Load ¶
func (l *StringList) Load(b []byte) error
func (*StringList) Size ¶
func (l *StringList) Size() int
type WaitGroupWrap ¶
func (*WaitGroupWrap) Wrap ¶
func (w *WaitGroupWrap) Wrap(cb func())
Click to show internal directories.
Click to hide internal directories.